On Tue, 13 Apr 2004, Tres Seaver wrote:

> Given that you trust yourself ;), you can add a security context from 
> within the second thread;  you could pass the user ID to the thread via 
> one of several forms of "currying", e.g. via instance variables::

I'm not sure if I trust myself in real life, but in this case I do. :)

Your code below did not work for me because I could not find the
newSecurityContext method.  However, I was able to use the 
SecurityManagement.newSecurityManager instead, and that worked great.
Thanks for pointing me in the right direction.

>    class TrustedSecurityTask:
>       def __init__(self, user_id):
>           self._user_id = user_id
>       def __call__(self, *args, **kw):
>           sm = getSecurityManager()
>           sm.newSecurityContext(None, User(self._user_id))
>           # your code here .....
>     thread = Thread(TrustedSecurityTask(user_id))
>     thread.start()
> Tres.

Take care,
Toby Gustafson
Senior Software Engineer
Tyrell Software Corporation

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to