开发者

How to add plone group members from script

开发者 https://www.devze.com 2023-03-16 13:02 出处:网络
I tried to add a plone user from a script that I ran with \"./bin/instance run myscript.py\" ipdb>app.Plone.portal_groups.addPrinci开发者_如何学CpalToGroup(\'newuser\', \'Administrators\')

I tried to add a plone user from a script that I ran with "./bin/instance run myscript.py"

ipdb>app.Plone.portal_groups.addPrinci开发者_如何学CpalToGroup('newuser', 'Administrators')
True

but when I check the web interface the user is not added to the group.

Although

ipdb>app.Plone.portal_groups.getGroupMembers('Administrators')
['newuser']

says otherwise.

When I run the same code in a normal plone instance (by opening a console with http://localhost:8080/Plone/ipdb) it works.

Do I have to commit the changes I made to ZODB or something like that?


You need to commit your transaction after doing all the changes

import transaction
# do some things
transaction.commit()
0

精彩评论

暂无评论...
验证码 换一张
取 消