[Zope3-dev] EventService, references, and subscription semantics
Steve Alexander
steve@cat-box.net
Mon, 25 Feb 2002 23:53:02 +0000
Steve Alexander wrote:
> Shane Hathaway wrote:
>
>>
>> Well, I may be wrong, but I don't think you can go that far. If you
>> have a persistent LDAP-backed user database and you want to register
>> an LDAP-based user object as an event listener (perhaps to expire the
>> user's password), how would the IReferenceLookup utility know to use a
>> path/userid-based reference as opposed to a persistence-based
>> reference or an LDAP-based reference? The only interface of the user
>> objects is IPrincipal.
>
>
> So, you configure your IReferenceLookup utility to make decisions based
> on the location/context of the object.
>
> Or, you make your Principals implement ILDAPLookedUp (in addition to
> IPrincipal), which the IReferenceLookup is configured to know about.
In fact, I think a neat answer would be for the IReferenceLookup to grab
an IReferenceLookupImplementation from the context of the object we want
an IReference for.
So, an object's context is responsible for providing a utility to say
how to make an appropriate kind of reference.
Root :-- IReferenceLookup (service)
/ \
Bar Foo
/ \
Baz LDAPUserFolder :-- IReferenceLookupUtility
\
LDAP Principal Object
So, object Baz gets the LDAP Principal Object (let's call it "user"). It
wants to store a reference to user:
1: Baz gets the IReferenceLookup service
2: Baz passes user to the IReferenceLookup service
3: The service examines user's context wrapper, and walks the wrapper
looking for an IReferenceLookupUtility
4; The service passes user to the IReferenceLookupUtility, which
returns an appropriate IReference object
Your LDAPUserFolder would be equipped with the nous to get for objects
in its context the appropriate kind of IReference.
The IReferenceLookup service could have sensible defaults (configured in
zcml), for when no IReferenceLookupUtility could be found, or when it
doesn't know what to do.
--
Steve Alexander