[Zope] Change user (pythonic)

Andreas Jung lists at andreas-jung.com
Sat Jul 16 14:04:53 EDT 2005



--On 16. Juli 2005 19:54:52 +0200 Jan-Ole Esleben <esleben at gmail.com> wrote:

> Hi!
>
> I can't seem to figure out from the documentation or through web
> research how it is possible to change the currently logged in user
> pythonically (e.g. in an fs product or extension method).
>
> Can anybody give me a hint?
>

Something like this should work (taken from zopewiki.org):

In [10]?: from AccessControl?.SecurityManagement? import 
newSecurityManager, getSecurityManager
In [11]?: user = app.acl_users.getUser('jean').__of__(app.portal.acl_users)
In [12]?: newSecurityManager(None, user)
In [13]?: getSecurityManager().getUser() # just to verify it.
Out[13]?: jean
In [14]?: app.fab.materials.invokeFactory('Material', 'test11')
In [15]?: mat = getattr(app.fab.materials, 'test11')
In [16]?: mat
Out[16]?: <Material at /fab/materials/test11>

-aj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20050716/ad87d444/attachment.bin


More information about the Zope mailing list