[Zope-dev] Re: start_new_thread / user issue

Toby Gustafson tobyg at tyrell.com
Tue Apr 13 13:38:58 EDT 2004


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.
---------------------------
Toby Gustafson
Senior Software Engineer
Tyrell Software Corporation
Email: tobyg at tyrell.com
---------------------------




More information about the Zope-Dev mailing list