[Zope3-dev] EventService, references, and subscription semantics

Shane Hathaway shane@zope.com
Mon, 25 Feb 2002 20:23:57 -0500 (EST)


On Mon, 25 Feb 2002, Steve Alexander wrote:

> 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.

That sounds reasonable for this case, but I don't think we've had enough
time to think to be designing a service yet.  Maybe we have, but I'd like
us to leave room for adding an event subscriber that either provides its
own reference, or doesn't need to use a reference at all.

Hmm, maybe that's not a problem: the addSubscriber() method of the event
service (or whatever the method is called) might accept either a reference
object or some other kind of object; if the object is not a reference then
the event service tries to make one for it.  That's a similar pattern to
what getAdapter() does.

I think IReferenceLookup is the wrong name--I think what you want is
something like IReferenceGenerator.  The IReferenceGenerator is only used
when creating a reference, not when dereferencing one, which the name
"IReferenceLookup" tends to imply (although the implementation might, at
its option, refer to the IReferenceGenerator that created it in order to
dererence.)

All things considered, this idea sounds very promising.

Shane