Using plone.api to create groups (solved!)

I'm trying to use plone.api to create groups. This example, taken from the documentation, doesn't produce any errors but also doesn't create the 'board_members' group.

This is a plain vanilla, fresh Plone 5.0.5 install using the unified installer to which I've only added Products.WebServerAuth to [eggs] in buildout. I'm launching this script with

sudo -u plone_daemon /opt/Plone-wsa/zeocluster/bin/client2 -O Plone run /var/tmp/

/var/tmp/ is:

from plone import api

group =
        title='Board members',
        description='Just a description',
        roles=['Reader', ],
        groups=['Site Administrators', ],

For what it's worth, I've used other plone.api methods successfully, e.g. I've used and api.user.get_users() without problem.


In irc, tkimnguyen pointed out that I needed to commit the transaction:

import transaction

Which works! (This is documented, I just missed it. Thanks, tkimnguyen!)