[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ remove ITransientLocation

Dominik Huber dominik.huber at projekt01.ch
Mon Jun 6 04:17:38 EDT 2005


Log message for revision 30654:
  remove ITransientLocation

Changed:
  U   Zope3/trunk/src/zope/app/intid/__init__.py
  U   Zope3/trunk/src/zope/app/intid/tests.py
  U   Zope3/trunk/src/zope/app/location/interfaces.py

-=-
Modified: Zope3/trunk/src/zope/app/intid/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/__init__.py	2005-06-05 17:27:20 UTC (rev 30653)
+++ Zope3/trunk/src/zope/app/intid/__init__.py	2005-06-06 08:17:36 UTC (rev 30654)
@@ -33,7 +33,6 @@
 from zope.app.container.contained import Contained
 from zope.app.keyreference.interfaces import IKeyReference, NotYet
 from zope.app.location.interfaces import ILocation
-from zope.app.location.interfaces import ITransientLocation
 
 from zope.app.intid.interfaces import IIntIds
 from zope.app.intid.interfaces import IntIdRemovedEvent
@@ -73,18 +72,14 @@
         return default
 
     def getId(self, ob):
-        if not ITransientLocation.providedBy(ob):
-            try:
-                ref = IKeyReference(ob)
-            except NotYet:
-                raise KeyError(ob)
+        try:
+            ref = IKeyReference(ob)
+        except NotYet:
+            raise KeyError(ob)
 
-            try:
-                return self.ids[ref]
-            except KeyError:
-                raise KeyError(ob)
-
-        else:
+        try:
+            return self.ids[ref]
+        except KeyError:
             raise KeyError(ob)
 
     def queryId(self, ob, default=None):
@@ -134,32 +129,30 @@
     id utilities.
     """
 
-    if not ITransientLocation.providedBy(ob): # do not unregister transient locations
-        # Notify the catalogs that this object is about to be removed.
-        notify(IntIdRemovedEvent(ob, event))
-    
-        for utility in zapi.getAllUtilitiesRegisteredFor(IIntIds, ob):
-            try:
-                utility.unregister(ob)
-            except KeyError:
-                pass
+    # Notify the catalogs that this object is about to be removed.
+    notify(IntIdRemovedEvent(ob, event))
 
+    for utility in zapi.getAllUtilitiesRegisteredFor(IIntIds, ob):
+        try:
+            utility.unregister(ob)
+        except KeyError:
+            pass
 
+
 def addIntIdSubscriber(ob, event):
     """A subscriber to ObjectAddedEvent
 
     Registers the object added in all unique id utilities and fires
     an event for the catalogs.
     """
-    # do not register transient locations
-    if not ITransientLocation.providedBy(ob):
-        for utility in zapi.getAllUtilitiesRegisteredFor(IIntIds):
-            utility.register(ob)
-    
-        # Notify the catalogs that this object was added.
-        notify(IntIdAddedEvent(ob, event))
 
+    for utility in zapi.getAllUtilitiesRegisteredFor(IIntIds):
+        utility.register(ob)
 
+    # Notify the catalogs that this object was added.
+    notify(IntIdAddedEvent(ob, event))
+
+
 # BBB
 UniqueIdUtility = IntIds
 import zope.app.keyreference.persistent

Modified: Zope3/trunk/src/zope/app/intid/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/tests.py	2005-06-05 17:27:20 UTC (rev 30653)
+++ Zope3/trunk/src/zope/app/intid/tests.py	2005-06-06 08:17:36 UTC (rev 30654)
@@ -27,17 +27,13 @@
 from zope.app.testing import setup, ztapi
 from zope.app import zapi
 from zope.app.location.interfaces import ILocation
-from zope.app.location.interfaces import ITransientLocation
 from zope.app.component.hooks import setSite
 
+
 class P(Persistent):
     implements(ILocation)
 
 
-class T(object):
-    implements(ITransientLocation)
-
-
 class ConnectionStub(object):
     next = 1
     def add(self, ob):
@@ -74,19 +70,16 @@
 
         u = IntIds()
         obj = P()
-        t_obj = T()
         
         obj._p_jar = ConnectionStub()
 
         self.assertRaises(KeyError, u.getId, obj)
-        self.assertRaises(KeyError, u.getId, t_obj)
         self.assertRaises(KeyError, u.getId, P())
         self.assertRaises(TypeError, u.getId, object())
 
         self.assert_(u.queryId(obj) is None)
         self.assert_(u.queryId(obj, 42) is 42)
         self.assert_(u.queryId(P(), 42) is 42)
-        self.assert_(u.queryId(t_obj) is None)
         self.assertRaises(TypeError, u.queryId, object())
         self.assert_(u.queryObject(42) is None)
         self.assert_(u.queryObject(42, obj) is obj)
@@ -194,11 +187,6 @@
         events = []
         ztapi.handle([IIntIdRemovedEvent], events.append)
 
-        # Transient locations should not be unregistered.
-        t = T()
-        removeIntIdSubscriber(t, ObjectRemovedEvent(parent_folder))
-        self.assertEquals(len(events), 0)
-
         # This should unregister the object in all utilities, not just the
         # nearest one.
         removeIntIdSubscriber(folder, ObjectRemovedEvent(parent_folder))
@@ -221,11 +209,6 @@
         events = []
         ztapi.handle([IIntIdAddedEvent], events.append)
 
-        # Transient locations should not be registered at all.
-        t = T()
-        addIntIdSubscriber(t, ObjectAddedEvent(parent_folder))
-        self.assertEquals(len(events), 0)
-
         # This should register the object in all utilities, not just the
         # nearest one.
         addIntIdSubscriber(folder, ObjectAddedEvent(parent_folder))

Modified: Zope3/trunk/src/zope/app/location/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/location/interfaces.py	2005-06-05 17:27:20 UTC (rev 30653)
+++ Zope3/trunk/src/zope/app/location/interfaces.py	2005-06-06 08:17:36 UTC (rev 30654)
@@ -42,10 +42,3 @@
         An iterable of objects whose __parent__ is the object
         providing the interface is returned.
         """
-
-
-class ITransientLocation(ILocation):
-    """Mark transient resp. none-persistent location explicitly.
-
-    Do not reference marked objects directly.
-    """



More information about the Zope3-Checkins mailing list