[Zope3-Users] Re: [Zope3-dev] services and utilities outside a context

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Nov 11 08:53:14 EST 2004


On Friday 29 October 2004 06:37, Alberto Degli Esposti wrote:
> I have a thread that do some task ouside a zope context. I need to get
> a reference to objects stored in the zodb, so, I used a local
> IUniqueIdUtility to get unique ids of the objects and I wrote the ids
> to a file. The thread read the file and try to use the utility to
> retrieve a reference to the object but,  I don't know how to get
> utilities or services with zapi.getService or getUtility without a
> ComponentLookupError. Is there a better way to store and retrieve a
> zodb object reference?

I'll take the answer over to zope3-users now that we have such a list. I CCed 
zope3-dev, so that the thread is complete in the archives.

Is this thread a fork from the main Zope 3 process or a completely new Python 
process? Depending of what you want to do in the thread, you could pass in 
the objects directly to the thread. Another possibility would be to store the 
path of the object, even though this might have the same problems as your 
approach. 

You get the error you have, because your thread does not have a participation, 
which is a thread global. You need to copy this thread global to you new 
thread and all the component lookups should work again. You might want to 
look at the publisher code to see how setting the participation and site in a 
athread is done.

If the above solution does nto describe a solution to your problem, I would 
need to see the traceback to make more sense of the problem.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list