[z3-five] local utilities
Martijn Faassen
faassen at infrae.com
Tue Aug 31 12:39:24 MEST 2004
Hi there,
This is a note to discuss what I'm up to, as I think I need help. :) I'm
trying to get local utilities (aka tools) working.
Why do I want to get these working? As I've announced in a previous
note, I have code checked in that sends Zope 3 events. It's possible to
catch these events by factories; basically module-level functions.
For this event-handling to become really useful though -- for instance
to build an archetypes-style unique id service, or even the Zope 3
catalog, we need ZODB-level objects that can track these events and
store information.
The Zope 3 pattern for this, I understand, is to get a local utility and
sending the events to this.
How does Zope 3 know that a local utility is even there? By ask the
site, which is a global associated with the thread.
How does Zope 3 know the current site? During traversal an event is sent
if a site object is encountered. This event his handled (globally) and
the thing is set.
What constitutes a site in Zope? It's an IPossibleSite, a simple enough
interface to support, that becomes an ISite, if a ISiteManager is set in
it. The site logic can be found in zope.app.site.
Unfortunately ISiteManager is *not* a simple interface; it inherits from
IServiceService, IComponentManager and registration.IRegistry. The
SiteManager implementation in zope.app.site.service is rather large. To
make matters more complicated, it's also implementing
IRegisterableContainerContainer in addition to ISiteManager. Backporting
this class to Zope 2 seems rather daunting.
Things in zope.app.site.servicecontainer give me some hope though -- it
turns out that the site manager only needs to provide IServiceService to
be accepted. This is a somewhat smaller, though of course a highly
abstract interface, which may make it harder to figure out what is required.
So, todo:
* backport the stuff in zope.app.site.servicecontainer to Zope 2. That
should be pretty simple.
* make our own implementation of a local IServiceService that does the
'right thing', whatever that is. There is all kinds of fallback behavior
on sites 'higher up' and finally the global site which we'll need to
make sure we support.
* make Zope 2's traverser machinery send out the right event as soon as
an ISite is encountered. I hope we can get away with doing a traversal
hook in the site class (i.e. our
zope.app.site.servicecontainer.ServiceManagerContainer, which implements
IPossibleSite) that sends this event.
And some hopes:
* we don't care right now about any user interface to the site manager.
I hope that means we don't need to care about all kinds of stuff.
* I hope we can get away with ignoring the whole registration logic. I
think that is only used by services, while we're right now only
interested in local utilities.
I hope that others can jump in with some answers, suggestions, testing
strategies, and maybe even code. :)
Regards,
Martijn
More information about the z3-five
mailing list