[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/ Updated change notification to pass the originally changed

Jim Fulton jim at zope.com
Tue Apr 25 09:22:35 EDT 2006


Log message for revision 67594:
  Updated change notification to pass the originally changed
  object. This is helpful for persistent objects that only have
  persistent changes if they were the originally changed object.
  

Changed:
  U   Zope3/branches/jim-adapter/src/zope/component/persistentregistry.py
  U   Zope3/branches/jim-adapter/src/zope/interface/adapter.py
  U   Zope3/branches/jim-adapter/src/zope/interface/declarations.py
  U   Zope3/branches/jim-adapter/src/zope/interface/interface.py

-=-
Modified: Zope3/branches/jim-adapter/src/zope/component/persistentregistry.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/persistentregistry.py	2006-04-25 13:22:30 UTC (rev 67593)
+++ Zope3/branches/jim-adapter/src/zope/component/persistentregistry.py	2006-04-25 13:22:32 UTC (rev 67594)
@@ -24,9 +24,10 @@
 class PersistentAdapterRegistry(zope.interface.adapter.AdapterRegistry,
                                 persistent.Persistent):
 
-    def changed(self):
-        self._p_changed = True
-        super(PersistentAdapterRegistry, self).changed()
+    def changed(self, originally_changed):
+        if originally_changed is self:
+            self._p_changed = True
+        super(PersistentAdapterRegistry, self).changed(originally_changed)
         
 class PersistentComponents(zope.component.registry.Components):
 

Modified: Zope3/branches/jim-adapter/src/zope/interface/adapter.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/interface/adapter.py	2006-04-25 13:22:30 UTC (rev 67593)
+++ Zope3/branches/jim-adapter/src/zope/interface/adapter.py	2006-04-25 13:22:32 UTC (rev 67594)
@@ -79,7 +79,7 @@
             
             self.__dict__['__bases__'] = v
             self.ro = ro.ro(self)
-            self.changed()
+            self.changed(self)
             
         return property(get, set)
 
@@ -90,16 +90,16 @@
         if r in self._v_subregistries:
             del self._v_subregistries[r]
 
-    def changed(self):
+    def changed(self, originally_changed):
         try:
             lookup = self._v_lookup
         except AttributeError:
             pass
         else:
-            lookup.changed()
+            lookup.changed(originally_changed)
 
         for sub in self._v_subregistries.keys():
-            sub.changed()
+            sub.changed(originally_changed)
        
     @readproperty
     def _v_extendors(self):
@@ -149,7 +149,7 @@
         if n == 1 and '_v_extendors' in self.__dict__:
             del self.__dict__['_v_extendors']
 
-        self.changed()
+        self.changed(self)
         
     def unregister(self, required, provided, name, value=None):
         required = tuple(map(_convert_None_to_Interface, required))
@@ -181,7 +181,7 @@
         else:
             self._provided[provided] = n
 
-        self.changed()
+        self.changed(self)
 
         return
 
@@ -211,7 +211,7 @@
             if n == 1 and '_v_extendors' in self.__dict__:
                 del self.__dict__['_v_extendors']
 
-        self.changed()
+        self.changed(self)
 
     def unsubscribe(self, required, provided, value=None):
         required = tuple(map(_convert_None_to_Interface, required))
@@ -240,7 +240,7 @@
                 if '_v_extendors' in self.__dict__:
                     del self.__dict__['_v_extendors']
 
-        self.changed()
+        self.changed(self)
 
         return
 
@@ -265,7 +265,7 @@
         self._scache = {}
         self._required = {}
 
-    def changed(self):
+    def changed(self, originally_changed):
         self._cache.clear()
         self._mcache.clear()
         self._scache.clear()

Modified: Zope3/branches/jim-adapter/src/zope/interface/declarations.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/interface/declarations.py	2006-04-25 13:22:30 UTC (rev 67593)
+++ Zope3/branches/jim-adapter/src/zope/interface/declarations.py	2006-04-25 13:22:32 UTC (rev 67594)
@@ -46,8 +46,8 @@
     def __init__(self, *interfaces):
         Specification.__init__(self, _normalizeargs(interfaces))
 
-    def changed(self):
-        Specification.changed(self)
+    def changed(self, originally_changed):
+        Specification.changed(self, originally_changed)
         try:
             del self._v_attrs
         except AttributeError:

Modified: Zope3/branches/jim-adapter/src/zope/interface/interface.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/interface/interface.py	2006-04-25 13:22:30 UTC (rev 67593)
+++ Zope3/branches/jim-adapter/src/zope/interface/interface.py	2006-04-25 13:22:32 UTC (rev 67594)
@@ -251,7 +251,7 @@
         for b in bases:
             b.subscribe(self)
 
-        self.changed()
+        self.changed(self)
 
     __bases__ = property(
 
@@ -259,7 +259,7 @@
         __setBases,
         )
 
-    def changed(self):
+    def changed(self, originally_changed):
         """We, or something we depend on, have changed
         """
 
@@ -285,7 +285,7 @@
 
         # Now, advise our dependents of change:
         for dependent in self.dependents.keys():
-            dependent.changed()
+            dependent.changed(originally_changed)
 
 
     def interfaces(self):



More information about the Zope3-Checkins mailing list