[CMF-checkins] CVS: CMF/CMFUid - UniqueIdHandlerTool.py:1.4

Grégoire Weber zope.org at incept.ch
Tue Jul 20 23:11:49 EDT 2004


Update of /cvs-repository/CMF/CMFUid
In directory cvs.zope.org:/tmp/cvs-serv14594

Modified Files:
	UniqueIdHandlerTool.py 
Log Message:
- minor cosmetic changes
- added forgotten import of zLOG causing an exception if more than one object exists with the same uid


=== CMF/CMFUid/UniqueIdHandlerTool.py 1.3 => 1.4 ===
--- CMF/CMFUid/UniqueIdHandlerTool.py:1.3	Tue Jul 20 21:26:11 2004
+++ CMF/CMFUid/UniqueIdHandlerTool.py	Tue Jul 20 23:11:19 2004
@@ -20,6 +20,7 @@
 
 import Missing
 
+import zLOG
 from Globals import InitializeClass, Persistent
 from AccessControl import ClassSecurityInfo
 from Acquisition import Implicit, aq_base
@@ -49,7 +50,7 @@
     
     # make the uid attribute name available for the unit tests
     # not meant to be altered!!!
-    _UID_ATTRIBUTE_NAME = UID_ATTRIBUTE_NAME
+    UID_ATTRIBUTE_NAME = UID_ATTRIBUTE_NAME
     
     # make the exception class available through the tool
     UniqueIdError = UniqueIdError
@@ -60,7 +61,7 @@
     def queryUid(self, obj, default=None):
         """See IUniqueIdQuery.
         """
-        uid = getattr(aq_base(obj), self._UID_ATTRIBUTE_NAME, None)
+        uid = getattr(aq_base(obj), self.UID_ATTRIBUTE_NAME, None)
         # If 'obj' is a content object the 'uid' attribute is usually a
         # callable object. If 'obj' is a catalog brain the uid attribute 
         # is non callable and possibly equals the 'Missing.MV' value.
@@ -86,7 +87,7 @@
         """
         uid = self.queryUid(obj, default=None)
         if uid is None:
-            UID_ATTRIBUTE_NAME = self._UID_ATTRIBUTE_NAME
+            UID_ATTRIBUTE_NAME = self.UID_ATTRIBUTE_NAME
             generator = getToolByName(self, 'portal_uidgenerator')
             setattr(obj, UID_ATTRIBUTE_NAME, generator())
             uid = getattr(obj, UID_ATTRIBUTE_NAME)
@@ -104,7 +105,7 @@
     def unregister(self, obj):
         """See IUniqueIdSet.
         """
-        UID_ATTRIBUTE_NAME = self._UID_ATTRIBUTE_NAME
+        UID_ATTRIBUTE_NAME = self.UID_ATTRIBUTE_NAME
         if getattr(aq_base(obj), UID_ATTRIBUTE_NAME, None) is None:
             raise UniqueIdError, \
                   "No unique id available to be unregistered on '%s'" % obj
@@ -125,7 +126,7 @@
             return default
         
         catalog = getToolByName(self, 'portal_catalog')
-        result = catalog({self._UID_ATTRIBUTE_NAME: uid})
+        result = catalog({self.UID_ATTRIBUTE_NAME: uid})
         len_result = len(result)
 
         # return None if no object found with this uid
@@ -136,7 +137,7 @@
         # the same uid (uups!)
         # TODO: It would be nice if there were a logging tool :-)
         if len_result > 1:
-            zLOG.LOG("UidTool ASSERT:", zLOG.INFO,
+            zLOG.LOG("CMUid ASSERT:", zLOG.INFO,
                      "Uups, %s objects have '%s' as uid!!!" % \
                      (len_result, uid))
         



More information about the CMF-checkins mailing list