mtool = context.portal_membership.aq_inner
pu = context.plone_utils.aq_inner
acl = context.acl_users.aq_inner
count = 0
for uid in acl.getUserIds():
count += 1
acl.userSetPassword(uid, uid)
member = mtool.getMemberById(uid)
pu.setMemberProperties(member, email='me.the.developper@mydomain.tld')
print uid
print count, "users"
return printed
Wednesday, January 21, 2009
Useful script in a plone developer toolbox
Sometimes something weird happen on the production site and you have to investigate on data from that site because you can't reproduce the problem on development site. When it's really hard you have to copy the Data.fs and run a separate instance to work on it. What I'm putting here is a script that changes all users passwords to their id, and also change email property: this allows to login as anybody easily, and no mail can be sent to the actual users. All you have to do is create a "Script (Python)" in ZMI at portal root, put this code and click "test". It's not a revolution, it's not-so-good-practice(tm), it's just a convenience ;-)
Libellés :
plone
Subscribe to:
Post Comments (Atom)
3 comments:
Nice!
Please consider posting this to Plone.Org as a how-to!
You can also use collective.steps with the step 'init_users_password'
cf http://pypi.python.org/pypi/collective.steps
@ToutPT: Interesting, I didn't knew about it. Can it run with a standalone instance or does it require a zeo client/server setup?
Post a Comment