[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/intid/ Revert changes to IIntIdsSet interface.

Dominik Huber dominik.huber at projekt01.ch
Thu Jun 9 10:41:22 EDT 2005


Log message for revision 30706:
  Revert changes to IIntIdsSet interface.
  

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

-=-
Modified: Zope3/trunk/src/zope/app/intid/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/__init__.py	2005-06-09 14:35:16 UTC (rev 30705)
+++ Zope3/trunk/src/zope/app/intid/__init__.py	2005-06-09 14:41:22 UTC (rev 30706)
@@ -104,13 +104,11 @@
                 return uid
             self._v_nextid = None
 
-    def register(self, ob_or_key):
+    def register(self, ob):
         # Note that we'll still need to keep this proxy removal.
-        key = removeSecurityProxy(ob_or_key)
+        ob = removeSecurityProxy(ob)
+        key = IKeyReference(ob)
 
-        if not IKeyReference.providedBy(key):
-            key = IKeyReference(key)
-
         if key in self.ids:
             return self.ids[key]
         uid = self._generateId()
@@ -118,13 +116,11 @@
         self.ids[key] = uid
         return uid
 
-    def unregister(self, ob_or_key):
+    def unregister(self, ob):
         # Note that we'll still need to keep this proxy removal.
-        key = removeSecurityProxy(ob_or_key)
+        ob = removeSecurityProxy(ob)
+        key = IKeyReference(ob)
 
-        if not IKeyReference.providedBy(key):
-            key = IKeyReference(key)
-
         uid = self.ids[key]
         del self.refs[uid]
         del self.ids[key]

Modified: Zope3/trunk/src/zope/app/intid/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/interfaces.py	2005-06-09 14:35:16 UTC (rev 30705)
+++ Zope3/trunk/src/zope/app/intid/interfaces.py	2005-06-09 14:41:22 UTC (rev 30706)
@@ -33,19 +33,16 @@
 
 class IIntIdsSet(Interface):
 
-    def register(ob_or_key):
-        """Register an object or a key reference and return a unique id.
+    def register(ob):
+        """Register an object and returns a unique id generated for it.
 
-        If the object adapted to key reference is already registered, its 
-        id is returned anyway otherwise,  a unique id is generated for it
-        and returned.
+        If the object is already registered, its id is returned anyway.
         """
 
-    def unregister(ob_or_key):
-        """Remove the object or the key reference from the indexes.
+    def unregister(ob):
+        """Remove the object from the indexes.
 
-        KeyError is raised if the object adapted to key reference is not
-        registered previously.
+        KeyError is raised if ob is not registered previously.
         """
 
 class IIntIdsManage(Interface):

Modified: Zope3/trunk/src/zope/app/intid/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/tests.py	2005-06-09 14:35:16 UTC (rev 30705)
+++ Zope3/trunk/src/zope/app/intid/tests.py	2005-06-09 14:41:22 UTC (rev 30706)
@@ -65,9 +65,8 @@
 
         verifyObject(IIntIds, IntIds())
 
-    def test_empty(self):
+    def test(self):
         from zope.app.intid import IntIds
-        from zope.app.keyreference.interfaces import IKeyReference
 
         u = IntIds()
         obj = P()
@@ -85,53 +84,6 @@
         self.assert_(u.queryObject(42) is None)
         self.assert_(u.queryObject(42, obj) is obj)
 
-        key = IKeyReference(obj)
-
-        uid = u.register(key)
-        self.assert_(u.getObject(uid) is obj)
-        self.assert_(u.queryObject(uid) is obj)
-        self.assertEquals(u.getId(obj), uid)
-        self.assertEquals(u.queryId(obj), uid)
-
-        uid2 = u.register(key)
-        self.assertEquals(uid, uid2)
-
-        u.unregister(key)
-        self.assertRaises(KeyError, u.getObject, uid)
-        self.assertRaises(KeyError, u.getId, obj)
-
-    def test_key(self):
-        from zope.app.intid import IntIds
-        from zope.app.keyreference.interfaces import IKeyReference
-
-        u = IntIds()
-        obj = P()
-        
-        obj._p_jar = ConnectionStub()
-
-        key = IKeyReference(obj)
-
-        uid = u.register(key)
-        self.assert_(u.getObject(uid) is obj)
-        self.assert_(u.queryObject(uid) is obj)
-        self.assertEquals(u.getId(obj), uid)
-        self.assertEquals(u.queryId(obj), uid)
-
-        uid2 = u.register(key)
-        self.assertEquals(uid, uid2)
-
-        u.unregister(key)
-        self.assertRaises(KeyError, u.getObject, uid)
-        self.assertRaises(KeyError, u.getId, obj)
-
-    def test_ob(self):
-        from zope.app.intid import IntIds
-
-        u = IntIds()
-        obj = P()
-        
-        obj._p_jar = ConnectionStub()
-
         uid = u.register(obj)
         self.assert_(u.getObject(uid) is obj)
         self.assert_(u.queryObject(uid) is obj)
@@ -221,15 +173,13 @@
         self.utility1 = setup.addUtility(sm1_1, '2', IIntIds, IntIds())
 
     def test_removeIntIdSubscriber(self):
-        from zope.app.container.contained import ObjectRemovedEvent
         from zope.app.intid import removeIntIdSubscriber
+        from zope.app.container.contained import ObjectRemovedEvent
         from zope.app.intid.interfaces import IIntIdRemovedEvent
-        from zope.app.keyreference.interfaces import IKeyReference
         parent_folder = self.root['folder1']['folder1_1']
         folder = self.root['folder1']['folder1_1']['folder1_1_1']
-        key = IKeyReference(folder)
-        id = self.utility.register(key)
-        id1 = self.utility1.register(key)
+        id = self.utility.register(folder)
+        id1 = self.utility1.register(folder)
         self.assertEquals(self.utility.getObject(id), folder)
         self.assertEquals(self.utility1.getObject(id1), folder)
         setSite(self.folder1_1)
@@ -271,7 +221,6 @@
         self.assertEquals(events[0].original_event.object, parent_folder)
         self.assertEquals(events[0].object, folder)
 
-
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(TestIntIds))



More information about the Zope3-Checkins mailing list