[Zope] Working with TransientObjectContainer
Thu, 27 Jun 2002 07:23:38 -0400
TransientObjectContainer's __init__ looks something like this:
def __init__(self, id,
For the "addNotification" and "delNotification" parameters you can pass=20
in either a Zope object path (to a Python Script or External Method,=20
generally) that refers to a callable object or a Python reference to a=20
callable object. The callable object needs to accept two parameters:=20
"item" and "container". At call time, "item" is the transient object=20
being notified and "container" is the transient object container.
The addNotification happens when an item is added to the container.
The delNotification happens right before an item is removed from
the container (usually as a result of the item expiring).
So if you create your own TransientObjectContainer with add and delete=20
notifiers, it might look something like this:
def add(self, item, container):
print "adding %s" % item
def del(self, item, container):
print "deleting %s" % item
toc =3D TransientObjectContainer(id=3D'toc', title=3D'', timeout_mins=3D2=
transient_object =3D toc.new_or_existing()
( will print "adding <TransientObject>")
... wait 20 minutes or so ...
( might print "deleting <TransientObject>", but may require several nudge=
Gilberto Gil Pereira wrote:
> Hi all!!!
> I'm working on a project that uses Zope (2.5.0) , but most of the work =
> done in Python (currently 2.1).
> The thing is that I'm trying to use the Python's class Transience to cr=
> transienteObjectyContainer that calls a method each time an object=20
> contained in it (mostly session objects) expires. The docs say that I c=
> this by defining a 'delNotification' when I create that object. So far =
> But when a call the class __init__ with an callable method, it is=20
> executed in compilation time, which means that the method is executed=20
> right away, insted of being executed when the object expires. I=B4ve al=
> tried to pass that method as a string (path+method_name), but Zope asks=
> for the Zope path, and not for the FS path that is used in Python.
> I'm sure I'm missing the big picture here, so if there's anyone out=20
> there that knows how i can do this, it would help a lot :)
> Zope maillist - Zope@zope.org
> ** No cross posts or HTML encoding! **
> (Related lists -=20
> http://lists.zope.org/mailman/listinfo/zope-dev )
Chris McDonough Zope Corporation
"Killing hundreds of birds with thousands of stones"