[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ Refactored the uniqueid package into two packages:

Jim Fulton jim at zope.com
Mon Nov 29 19:36:51 EST 2004


Log message for revision 28538:
  Refactored the uniqueid package into two packages:
  
    keyreference -- provides key references.
  
    intid -- provides integer-id management.
   
  Also rewrote the keyreference tests as a doctest. (It would be nice to
  do the same for the intid tests.)
  

Changed:
  U   Zope3/trunk/src/zope/app/catalog/README.txt
  U   Zope3/trunk/src/zope/app/catalog/catalog.py
  U   Zope3/trunk/src/zope/app/catalog/configure.zcml
  U   Zope3/trunk/src/zope/app/catalog/tests.py
  U   Zope3/trunk/src/zope/app/configure.zcml
  A   Zope3/trunk/src/zope/app/intid/
  UU  Zope3/trunk/src/zope/app/intid/__init__.py
  _U  Zope3/trunk/src/zope/app/intid/browser/__init__.py
  _U  Zope3/trunk/src/zope/app/intid/browser/configure.zcml
  _U  Zope3/trunk/src/zope/app/intid/browser/ftests.py
  _U  Zope3/trunk/src/zope/app/intid/browser/registrations.pt
  _U  Zope3/trunk/src/zope/app/intid/browser/tracking.txt
  _U  Zope3/trunk/src/zope/app/intid/configure.zcml
  _U  Zope3/trunk/src/zope/app/intid/ftests.py
  _U  Zope3/trunk/src/zope/app/intid/interfaces.py
  _U  Zope3/trunk/src/zope/app/intid/tests.py
  A   Zope3/trunk/src/zope/app/keyreference/
  _U  Zope3/trunk/src/zope/app/keyreference/__init__.py
  _U  Zope3/trunk/src/zope/app/keyreference/configure.zcml
  _U  Zope3/trunk/src/zope/app/keyreference/interfaces.py
  _U  Zope3/trunk/src/zope/app/keyreference/persistent.py
  _U  Zope3/trunk/src/zope/app/keyreference/persistent.txt
  _U  Zope3/trunk/src/zope/app/keyreference/tests.py
  D   Zope3/trunk/src/zope/app/uniqueid/

-=-
Modified: Zope3/trunk/src/zope/app/catalog/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/catalog/README.txt	2004-11-30 00:21:14 UTC (rev 28537)
+++ Zope3/trunk/src/zope/app/catalog/README.txt	2004-11-30 00:36:51 UTC (rev 28538)
@@ -14,7 +14,7 @@
       to spcify a names filter adapter.
 
 Catalogs use a unique-id tool to assign short (integer) ids to
-objects.  Before creating a catalog, you must create a uniqueid tool:
+objects.  Before creating a catalog, you must create a intid tool:
 
   >>> print http(r"""
   ... POST /++etc++site/default/AddUtility/action.html HTTP/1.1
@@ -23,17 +23,17 @@
   ... Content-Type: application/x-www-form-urlencoded
   ... Referer: http://localhost:8081/++etc++site/default/AddUtility
   ... 
-  ... type_name=BrowserAdd__zope.app.uniqueid.UniqueIdUtility&id=&add=+Add+""")
+  ... type_name=BrowserAdd__zope.app.intid.IntIds&id=&add=+Add+""")
   HTTP/1.1 303 ...
 
 And register it:
 
   >>> print http(r"""
-  ... POST /++etc++site/default/UniqueIdUtility/addRegistration.html HTTP/1.1
+  ... POST /++etc++site/default/IntIds/addRegistration.html HTTP/1.1
   ... Authorization: Basic bWdyOm1ncnB3
   ... Content-Length: 864
   ... Content-Type: multipart/form-data; boundary=---------------------------68417209514430962931254091825
-  ... Referer: http://localhost:8081/++etc++site/default/UniqueIdUtility/addRegistration.html
+  ... Referer: http://localhost:8081/++etc++site/default/IntIds/addRegistration.html
   ... 
   ... -----------------------------68417209514430962931254091825
   ... Content-Disposition: form-data; name="field.name"
@@ -42,7 +42,7 @@
   ... -----------------------------68417209514430962931254091825
   ... Content-Disposition: form-data; name="field.interface"
   ... 
-  ... zope.app.uniqueid.interfaces.IUniqueIdUtility
+  ... zope.app.intid.interfaces.IIntIds
   ... -----------------------------68417209514430962931254091825
   ... Content-Disposition: form-data; name="field.interface-empty-marker"
   ... 

Modified: Zope3/trunk/src/zope/app/catalog/catalog.py
===================================================================
--- Zope3/trunk/src/zope/app/catalog/catalog.py	2004-11-30 00:21:14 UTC (rev 28537)
+++ Zope3/trunk/src/zope/app/catalog/catalog.py	2004-11-30 00:36:51 UTC (rev 28538)
@@ -25,7 +25,7 @@
 from zope.app.annotation.interfaces import IAttributeAnnotatable
 from zope.app.container.interfaces import IContainer
 from zope.app.catalog.interfaces import ICatalog
-from zope.app.uniqueid.interfaces import IUniqueIdUtility
+from zope.app.intid.interfaces import IIntIds
 from zope.index.interfaces import ISimpleQuery
 
 
@@ -64,13 +64,13 @@
             index.unindex_doc(docid)
 
     def updateIndex(self, index):
-        uidutil = zapi.getUtility(IUniqueIdUtility)
+        uidutil = zapi.getUtility(IIntIds)
         for uid, ref in uidutil.items():
             obj = ref()
             index.index_doc(uid, obj)
 
     def updateIndexes(self):
-        uidutil = zapi.getUtility(IUniqueIdUtility)
+        uidutil = zapi.getUtility(IIntIds)
         for uid, ref in uidutil.items():
             obj = ref()
             for index in self.values():
@@ -96,7 +96,7 @@
             if not pendingResults:
                 break # nothing left, short-circuit
         # Next we turn the IISet of docids into a generator of objects
-        uidutil = zapi.getUtility(IUniqueIdUtility)
+        uidutil = zapi.getUtility(IIntIds)
         results = ResultSet(pendingResults, uidutil)
         return results
 
@@ -122,10 +122,10 @@
     index.__parent__.updateIndex(index)
     
 def indexDocSubscriber(event):
-    """A subscriber to UniqueIdAddedEvent"""
+    """A subscriber to IntIdAddedEvent"""
     for cat in zapi.getAllUtilitiesRegisteredFor(ICatalog):
         ob = event.object
-        id = zapi.getUtility(IUniqueIdUtility, context=cat).getId(ob)
+        id = zapi.getUtility(IIntIds, context=cat).getId(ob)
         cat.index_doc(id, ob)
 
 
@@ -133,15 +133,15 @@
     """A subscriber to ObjectModifiedEvent"""
     for cat in zapi.getAllUtilitiesRegisteredFor(ICatalog):
         ob = event.object
-        id = zapi.getUtility(IUniqueIdUtility, context=cat).queryId(ob)
+        id = zapi.getUtility(IIntIds, context=cat).queryId(ob)
         if id is not None:
             cat.index_doc(id, ob)
 
 
 def unindexDocSubscriber(event):
-    """A subscriber to UniqueIdRemovedEvent"""
+    """A subscriber to IntIdRemovedEvent"""
     for cat in zapi.getAllUtilitiesRegisteredFor(ICatalog):
         ob = event.object
-        id = zapi.getUtility(IUniqueIdUtility, context=cat).queryId(ob)
+        id = zapi.getUtility(IIntIds, context=cat).queryId(ob)
         if id is not None:
             cat.unindex_doc(id)

Modified: Zope3/trunk/src/zope/app/catalog/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/catalog/configure.zcml	2004-11-30 00:21:14 UTC (rev 28537)
+++ Zope3/trunk/src/zope/app/catalog/configure.zcml	2004-11-30 00:36:51 UTC (rev 28538)
@@ -35,7 +35,7 @@
 
 <subscriber
     factory=".catalog.indexDocSubscriber"
-    for="zope.app.uniqueid.interfaces.IUniqueIdAddedEvent"
+    for="zope.app.intid.interfaces.IIntIdAddedEvent"
     />
 
 <subscriber
@@ -45,7 +45,7 @@
 
 <subscriber
     factory=".catalog.unindexDocSubscriber"
-    for="zope.app.uniqueid.interfaces.IUniqueIdRemovedEvent"
+    for="zope.app.intid.interfaces.IIntIdRemovedEvent"
     />
 
 

Modified: Zope3/trunk/src/zope/app/catalog/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/catalog/tests.py	2004-11-30 00:21:14 UTC (rev 28537)
+++ Zope3/trunk/src/zope/app/catalog/tests.py	2004-11-30 00:36:51 UTC (rev 28538)
@@ -26,7 +26,7 @@
 from zope.app.tests import ztapi, setup
 from zope.app.tests.placelesssetup import PlacelessSetup
 from BTrees.IIBTree import IISet
-from zope.app.uniqueid.interfaces import IUniqueIdUtility
+from zope.app.intid.interfaces import IIntIds
 
 from zope.index.interfaces import IInjection, ISimpleQuery
 from zope.app.catalog.interfaces import ICatalog
@@ -45,9 +45,9 @@
         return self.obj
 
 
-class UniqueIdUtilityStub:
-    """A stub for UniqueIdUtility."""
-    implements(IUniqueIdUtility)
+class IntIdsStub:
+    """A stub for IntIds."""
+    implements(IIntIds)
 
     def __init__(self):
         self.ids = {}
@@ -132,9 +132,9 @@
         del catalog['author']
         self.assertEqual(list(catalog.keys()), ['title'])
 
-    def _frob_uniqueidutil(self, ints=True, apes=True):
-        uidutil = UniqueIdUtilityStub()
-        ztapi.provideUtility(IUniqueIdUtility, uidutil)
+    def _frob_intidutil(self, ints=True, apes=True):
+        uidutil = IntIdsStub()
+        ztapi.provideUtility(IIntIds, uidutil)
         # whack some objects in our little objecthub
         if ints:
             for i in range(10):
@@ -151,7 +151,7 @@
 
     def test_updateindexes(self):
         """Test a full refresh."""
-        self._frob_uniqueidutil()
+        self._frob_intidutil()
         catalog = Catalog()
         catalog['author'] = StubIndex('author', None)
         catalog['title'] = StubIndex('author', None)
@@ -162,7 +162,7 @@
 
     def test_updateindex(self):
         """Test a full refresh."""
-        self._frob_uniqueidutil()
+        self._frob_intidutil()
         catalog = Catalog()
         catalog['author'] = StubIndex('author', None)
         catalog['title'] = StubIndex('author', None)
@@ -174,7 +174,7 @@
 
     def test_basicsearch(self):
         """Test the simple search results interface."""
-        self._frob_uniqueidutil(ints=0)
+        self._frob_intidutil(ints=0)
         catalog = Catalog()
         catalog['simiantype'] = StubIndex('simiantype', None)
         catalog['name'] = StubIndex('name', None)
@@ -230,7 +230,7 @@
         sm = zapi.getServices(self.root)
         setup.addService(sm, Utilities, LocalUtilityService())
         self.utility = setup.addUtility(
-            sm, '', IUniqueIdUtility, UniqueIdUtilityStub())
+            sm, '', IIntIds, IntIdsStub())
         self.cat = setup.addUtility(sm, '', ICatalog, CatalogStub())
 
     def tearDown(self):
@@ -239,13 +239,13 @@
     def test_indexDocSubscriber(self):
         from zope.app.catalog.catalog import indexDocSubscriber
         from zope.app.container.contained import ObjectAddedEvent
-        from zope.app.uniqueid.interfaces import UniqueIdAddedEvent
+        from zope.app.intid.interfaces import IntIdAddedEvent
 
         ob = Stub()
         ob2 = Stub()
 
         id = self.utility.register(ob)
-        indexDocSubscriber(UniqueIdAddedEvent(ob, ObjectAddedEvent(ob2)))
+        indexDocSubscriber(IntIdAddedEvent(ob, ObjectAddedEvent(ob2)))
 
         self.assertEqual(self.cat.regs, [(id, ob)])
         self.assertEqual(self.cat.unregs, [])
@@ -271,7 +271,7 @@
     def test_unindexDocSubscriber(self):
         from zope.app.catalog.catalog import unindexDocSubscriber
         from zope.app.container.contained import ObjectRemovedEvent
-        from zope.app.uniqueid.interfaces import UniqueIdRemovedEvent
+        from zope.app.intid.interfaces import IntIdRemovedEvent
 
         ob = Stub()
         ob2 = Stub()
@@ -279,12 +279,12 @@
         id = self.utility.register(ob)
 
         unindexDocSubscriber(
-            UniqueIdRemovedEvent(ob2, ObjectRemovedEvent(ob3)))
+            IntIdRemovedEvent(ob2, ObjectRemovedEvent(ob3)))
         self.assertEqual(self.cat.unregs, [])
         self.assertEqual(self.cat.regs, [])
 
         unindexDocSubscriber(
-            UniqueIdRemovedEvent(ob, ObjectRemovedEvent(ob3)))
+            IntIdRemovedEvent(ob, ObjectRemovedEvent(ob3)))
         self.assertEqual(self.cat.unregs, [id])
         self.assertEqual(self.cat.regs, [])
 

Modified: Zope3/trunk/src/zope/app/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/configure.zcml	2004-11-30 00:21:14 UTC (rev 28537)
+++ Zope3/trunk/src/zope/app/configure.zcml	2004-11-30 00:36:51 UTC (rev 28538)
@@ -57,7 +57,8 @@
 
   <!-- Utilities -->
   <include package="zope.app.schema" />
-  <include package="zope.app.uniqueid" />
+  <include package="zope.app.intid" />
+  <include package="zope.app.keyreference" />
 
   <!-- Misc. Service Manager objects -->
   <include package="zope.app.module" />

Copied: Zope3/trunk/src/zope/app/intid (from rev 28537, Zope3/branches/jim-uniqueid-restructure/src/zope/app/intid)

Modified: Zope3/trunk/src/zope/app/intid/__init__.py
===================================================================
--- Zope3/branches/jim-uniqueid-restructure/src/zope/app/intid/__init__.py	2004-11-30 00:21:14 UTC (rev 28537)
+++ Zope3/trunk/src/zope/app/intid/__init__.py	2004-11-30 00:36:51 UTC (rev 28538)
@@ -138,8 +138,9 @@
 
 # BBB
 UniqueIdUtility = IntIds
-import zope.app.keyreference
-ReferenceToPersistent = zope.app.keyreference.KeyReferenceToPersistent
+import zope.app.keyreference.persistent
+ReferenceToPersistent = (
+    zope.app.keyreference.persistent.KeyReferenceToPersistent)
 import sys
 sys.modules['zope.app.uniqueid'] = sys.modules['zope.app.intid']
 del sys

Copied: Zope3/trunk/src/zope/app/keyreference (from rev 28537, Zope3/branches/jim-uniqueid-restructure/src/zope/app/keyreference)



More information about the Zope3-Checkins mailing list