[Zope3-checkins] CVS: Zope3/src/zope/app/services - interface.py:1.18

Jim Fulton cvs-admin at zope.org
Fri Nov 21 12:10:04 EST 2003


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

Modified Files:
	interface.py 
Log Message:
Updated persistent interfaces to reflect recent changes, including
converting dependencies to persistent dict rather than weakref dict.


=== Zope3/src/zope/app/services/interface.py 1.17 => 1.18 ===
--- Zope3/src/zope/app/services/interface.py:1.17	Sun Sep 21 13:31:59 2003
+++ Zope3/src/zope/app/services/interface.py	Fri Nov 21 12:10:03 2003
@@ -20,6 +20,7 @@
 """
 
 from persistence import Persistent
+from persistence.dict import PersistentDict
 from zodb.code.patch import registerWrapper, Wrapper
 from zope.interface.interface import InterfaceClass
 from zope.interface.interfaces import IInterface
@@ -36,7 +37,12 @@
 from zope.app.interfaces.services.registration import IRegistrationStack
 
 class PersistentInterfaceClass(Persistent, InterfaceClass):
-    pass
+
+    def __init__(self, *args, **kw):
+        Persistent.__init__(self)
+        InterfaceClass.__init__(self, *args, **kw)
+
+        self.dependents = PersistentDict()
 
 # PersistentInterface is equivalent to the zope.interface.Interface object
 # except that it is also persistent.  It is used in conjunction with
@@ -50,9 +56,18 @@
         return PersistentInterfaceClass(self._obj.__name__)
 
 
+def getInterfaceStateForPersistentInterfaceCreation(iface):
+    # Need to convert the dependents weakref dict to a persistent dict
+    dict = iface.__dict__.copy()
+    dependents = PersistentDict()
+    for k, v in dict['dependents'].iteritems():
+        dependents[k] = v
+    dict['dependents'] = dependents
+    return dict
+
 registerWrapper(InterfaceClass, PersistentInterfaceWrapper,
                 lambda iface: (),
-                lambda iface: iface.__dict__,
+                getInterfaceStateForPersistentInterfaceCreation,
                 )
 
 
@@ -122,4 +137,3 @@
             return [match for match in matching
                     if match[0].find(search_string) > -1]
         return matching
-




More information about the Zope3-Checkins mailing list