[Zope3-checkins] CVS: Zope3/src/zope/app/services - module.py:1.10

Guido van Rossum guido@python.org
Mon, 2 Jun 2003 13:45:11 -0400


Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv11421

Modified Files:
	module.py 
Log Message:
The Manager should call remove() when it is removed.  Arrange for this
to happen by implementing IDeleteNotifiable.


=== Zope3/src/zope/app/services/module.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/services/module.py:1.9	Mon Jun  2 12:24:33 2003
+++ Zope3/src/zope/app/services/module.py	Mon Jun  2 13:45:10 2003
@@ -30,10 +30,11 @@
 from zope.app.fssync.classes import ObjectEntryAdapter, AttrMapping
 from zope.app.interfaces.fssync import IObjectFile
 from zope.app.interfaces.file import IFileFactory
+from zope.app.interfaces.container import IDeleteNotifiable
 from zope.app.context import ContextWrapper
 
 
-class Registry:
+class Registry(Persistent):
 
     # This is a wrapper around the module service, which is actually
     # the service manager.  The service manager is found via context,
@@ -69,7 +70,7 @@
 
 class Manager(Persistent):
 
-    implements(IPersistentModuleManager)
+    implements(IPersistentModuleManager, IDeleteNotifiable)
 
     # The registry for the manager is the ServiceManager.
     # The association between this manager and the registry
@@ -105,6 +106,10 @@
 
     name = property(lambda self: self._manager.name)
     source = property(lambda self: self._manager.source)
+
+    def beforeDeleteHook(self, obj, container):
+        obj.remove()
+    beforeDeleteHook = ContextMethod(beforeDeleteHook)
 
 
 class ModuleAdapter(ObjectEntryAdapter):