Hi Gliberto, TransientObjectContainer's __init__ looks something like this: def __init__(self, id, title='', timeout_mins=20, addNotification=None, delNotification=None): For the "addNotification" and "delNotification" parameters you can pass in either a Zope object path (to a Python Script or External Method, generally) that refers to a callable object or a Python reference to a callable object. The callable object needs to accept two parameters: "item" and "container". At call time, "item" is the transient object 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 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 = TransientObjectContainer(id='toc', title='', timeout_mins=20, addNotification=add, delNotification=del) transient_object = toc.new_or_existing() ( will print "adding <TransientObject>") ... wait 20 minutes or so ... toc.nudge() ( might print "deleting <TransientObject>", but may require several nudges) HTH, - C Gilberto Gil Pereira wrote:
Hi all!!!
I'm working on a project that uses Zope (2.5.0) , but most of the work is done in Python (currently 2.1).
The thing is that I'm trying to use the Python's class Transience to create a transienteObjectyContainer that calls a method each time an object contained in it (mostly session objects) expires. The docs say that I can do this by defining a 'delNotification' when I create that object. So far so good... But when a call the class __init__ with an callable method, it is executed in compilation time, which means that the method is executed right away, insted of being executed when the object expires. I´ve also 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 there that knows how i can do this, it would help a lot :)
Cheers Gil
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Chris McDonough Zope Corporation http://www.zope.org http://www.zope.com "Killing hundreds of birds with thousands of stones"