Automating Plone setups - Faking a Zope userSo I've setup our Plone demo site,
again after a long hiatus. It includes a script to setup Plone instances automatically as users register with their email address.
In that process I discovered that the Plone installation (setup) scripts stopped working properly if an unauthenticated user was running the External Method that sets up the sites (workflowexception, no action for object).
After a little thinking I figured that the problem might be the login status of the user registering as the registration was working fine when being run by the admin (logged-in) user.
So I created this script:
Which overrides the standard security context and enables one to fake a Zope user from an acl_users folder, or simply fake a system user such as system or nobody.
The product won't change the actual logged-in (or anonymous user) for example when looking at the undo tab, but it does the trick for the workflow machinery which accepts whatever user you select or specify when calling FakeZopeUser.FakeUser.
[Update, demo site now works as it should, so try again if it didn't]
[Permalink] [By morphex] [Python, Zope, Plone - and anything loosely related to that (Atom feed)] [2012 05 Mar 09:33 GMT+2]
By: Matthew Wilkes
Manipulating private attributes of the security manager like this is a bad idea, just use newSecurityManager with the user you want to move into, and then move back to the old security manager when you're done.
The documentation on this is here: http://collective-docs.readthedocs.org/en/latest/security/permissions.html
I don't recommend anyone use this product over the existing API.