[Zope3-Users] Re: looking for something like getUtilitiesFor...
chris at simplistix.co.uk
Tue Sep 19 04:23:59 EDT 2006
Philipp von Weitershausen wrote:
> Chris Withers wrote:
>> Philipp von Weitershausen wrote:
>>> Utilities are never created when they're looked up. They're created
>>> when registered. Singletons (instances) are registered with the
>>> utility registry, never factories.
>> Ah, yes, of course, I think I'm looking for local utilities...
> But even global utilities are *first* instantiated from their factory,
> then registered as singleton instances.
Yes, that's true, but unrelated...
In fact, in this case, the utilities that are global are just python
functions marked with directlyProvides ;-)
>> Hmm, okay, how have the UI's for the creation of local utilities been
>> built? (I'm thinking there must be some kind of drop-down somewhere
>> with an "Add list" as in Zope 2's ZMI, and that must include the
>> available types of local utility?)
> Sure. Just use the standard "Add" menu in Zope 3. Some of the items
> there are potential local utilities, such as the Catalog, Cookie Client
> Id Manager, Error Logging Utiltiy, etc. You can add these objects
> anywhere, though it is recommended to do it within ++etc++site. The
> thing that makes them available as utilities is the registration. All
> objects have a "Registration" tab.
Ah, I see, so rather than using ZCML, you use the Registrations tab?
(now I'm dying to know if this has been implemented in Zope 2/Five)
That said, when you add a local utility in Zope 3, does it automatically
register itself by default? It'd be quite annoying to have to:
1. add you thing that uses local utilities
2. oops, actually have to go create the local utility
3. great, now I have to register the damn local utility
4. finally, I can go back and tell my thing to use the new local utility
Ideally there'd be some way to do steps 2-4 automatically, but at the
very least, having to manually do 3 seems superfluous, although I do
like the idea of being able to manually un-register a utility...
>> Also, more theoretically, would you see indexes for a catalog as being
>> local utilities. If not, what would you see them as being?
> The catalog is the local utility.
That's also true, but also not really what I was getting at ;-)
> It functions as a container for
Indeed, and how are these indices managed? For me, an Index is a local
(and potentially or maybe even definitely local to only that catalog)
utility for ICatalogIndex (or whatever it may be called). For me it'd be
nice to register the types of indexes using something like (and this is
all pseudo code):
...so you then have your list of addable index types.
How _is_ this done in Zope 3?
Simplistix - Content Management, Zope & Python Consulting
More information about the Zope3-users