[Zope-PTK] Re: [Zope-dev] Observable Interface?
Tres Seaver
tseaver@digicool.com
Fri, 10 Nov 2000 12:19:22 -0500 (EST)
On Fri, 10 Nov 2000, Chris Withers wrote:
> Does this mean all of the classes in the diagram at that URL have been
> implemented?
> How come the Catalog doesn't use it so CatalogAware
> (bleugh!) isn't needed anymore?
Heh, because we would have to make far-reaching changes
(essentially, add an event channel :) to make CA redundant;
otherwise, the catalog has no way to know *which* objects to
observe (not to mention the problem of maintaining tens of
thousands of point-to-point subscriptions within the catalog).
Chris Petrilli is working on a fishbowl proposal for CatalogNG;
I'm pretty sure he intends to adopt some kind of observer/event
scheme to make it work.
> Also, is there any documentation about how to actually use the
> Observable interface? (excuse my ignorance if I've missed it...)
Again, the wiki is it; the code deployed in Zope 2.2 implements
the Observable interface, and is intended to be used as a mix-in,
like so:
from OFS.SimpleItem import SimpleItem
from OFS.DefaultObservable import DefaultObservable
class Foo( SimpleItem, DefaultObservable ):
"""
Some foo or other
"""
...
def bar( self, ... ):
"""
"""
...
self.notify( "bar" )
Clients register with a Foo instance using the methods of the
Observable interface, e.g.:
foo.registerObserver( self.getPhysicalPath() + ( 'watchFoo',) )
When the Foo instance has its 'bar()' method called, it will
notify all registered observers, passing 'bar' as the event; in
this case, the client's 'watchFoo()' method will be called, with
the foo object and 'bar' passed as parameters.
(Thanks for the prodding -- I just checked in a docstring
containing the substance of this email.)
Tres.
--
===============================================================
Tres Seaver tseaver@digicool.com
Digital Creations "Zope Dealers" http://www.zope.org