[Zope3-Users] Re: sqlos, sites and local utilities
Philipp von Weitershausen
philipp at weitershausen.de
Thu Jan 5 10:44:47 EST 2006
Jeff Shell wrote:
> What about using zope.app.component.hooks.setSite? It sets the site on
> a zope.thread.local based object, and I believe most utility lookups
> fall back on that setting if context is not supplied.
All component look-ups *first* look at the closest site (which comes
from the thread local) and then cascade back to less local sites until
the global site is queried. Describing this as "falling back" on local
sites for "most utility lookups" is incorrect.
Now, the Component Architecture itself doesn't actually know about the
site in the thread local. It needs to be told to look there. That's
where the component hooks play a role. zope.app.component install those
to make zope.component look for the thread local. Unless these hooks
aren't installed, a site in the thread local won't be found. In Zope X3
3.0, these hooks were set via ZCML, in Zope 3.1+ you have to call
zope.app.component.hooks.setHooks(). That bit me at least twice when I
ported Five to Zope 3.2.
Philipp
More information about the Zope3-users
mailing list