[Zope3-dev] Local Utility-Service and persistent Utilities
Jim Fulton
jim@zope.com
Mon, 06 Jan 2003 14:37:21 -0500
Ulrich Eck wrote:
> At several parts of my work (schedule, workflow) i needed persistent
> Utilities
> so i decided to start work on them.
>
> Before i can start i need some information about the way it should be done.
>
> General structure:
>
> - A Local-UtilityService that is configured with the Service Manager
> - A Component that is added to some package
> - This Component is configured with the UtilityService
>
> My Questions:
>
> 1. What information is needed to configure a utility-component ?
> My Guess:
> - providedInterface (the interface the component provides or
> choosen TTW)
> - utilityName (an optional name)
Right.
> - componentPath (the path to the utility-component)
> so the Configuration key would be a tuple (providedInterface,
> utilityName) ??
Right, but this is almost an implementation detail.
The Utility configuration object will use a component path
internally and provide a getComponent method to retrieve the
utility it configures.
> 2. What components can be configured as Utilities ?
Any object that provides the desired interface can be configured as
a utility.
> When building the Configuration Screens i need to give a choice of
> components
> that can be configured as Utilities. How do i find out which one are
> avaliable ??
> afaik there is not common Interface for Utilities.
First (absent Javascript magic), get the user to select an interface,
then call queryComponent (see src/zope/app/interfaces/services/service.py)
on the service manager to find the components that provide that interface.
> 3. Should there be a possiblity to add persistently added
> component-instances as well
> as python-based (like global Utilities) ones ??
Yes, I thought that's what you were talking about, since components
created in modules don't have "paths".
> 4. How does resolving Utilities work when they have a name ?
getUtility(IFoo, name="spam")
> from the sources it seems, that when a utility is provided with
> name, it is not
> found when one queries only for the interface it provides .. is this
> behaviour
> correct and wanted ??
Yes.
> 5. How is registration/configuration handled when:
> - two utilities provide the same interface (no name) --> exclusive
> activation.
Yes, only one can be active.
> - two utilities provide same name and interface --> exclusive
> activiation.
ditto
> - one util provides interface - no name, other provides the same
> interface with name ?
They are different utilities. There is no conflict.
> - two utilities provide different interfaces for the same name ?
Ditto.
> I would basically start with adapter-service as template, add specific
> configuration-code,
> use the ImplementorRegistry (made persistent) to store
> Utility-configuration
> and build a TTW-Config-screen.
Right. Internally, you'll have a PersistentDict from utility name,
to ImplementorRegistry objects for each name.
> What else should i take care of when start working on this issue ??
You'll need a searching UI as in the adapter service.
This is not a small task. :)
If you need this for workflow, I'd be willing to do it for you so
you can focus on workflow.
> thanks for your comments
You're welcome.
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org