[CMF-checkins] CVS: CMF/CMFUid - UniqueIdAnnotationTool.py:1.7.2.2

Yvo Schubbe y.2004_ at wcm-solutions.de
Fri Aug 27 04:16:52 EDT 2004


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

Modified Files:
      Tag: CMF-1_5-branch
	UniqueIdAnnotationTool.py 
Log Message:
- added nested folder test and made it pass
- fixed broken excepts
- some whitespace cleanup


=== CMF/CMFUid/UniqueIdAnnotationTool.py 1.7.2.1 => 1.7.2.2 ===
--- CMF/CMFUid/UniqueIdAnnotationTool.py:1.7.2.1	Wed Aug 25 10:37:09 2004
+++ CMF/CMFUid/UniqueIdAnnotationTool.py	Fri Aug 27 04:16:21 2004
@@ -19,48 +19,49 @@
 
 from Globals import InitializeClass, Persistent
 from AccessControl import ClassSecurityInfo
-from Acquisition import Implicit, aq_base
+from Acquisition import aq_base, aq_inner, aq_parent
+from Acquisition import Implicit
 
 from OFS.PropertyManager import PropertyManager
 from OFS.SimpleItem import SimpleItem
 
 from Products.CMFCore.utils import getToolByName, UniqueObject
 from Products.CMFCore.ActionProviderBase import ActionProviderBase
-from Products.CMFCore.permissions import ManagePortal
 
 from Products.CMFUid.interfaces import IUniqueIdAnnotation
 from Products.CMFUid.interfaces import IUniqueIdAnnotationManagement
 
+
 class UniqueIdAnnotation(Persistent, Implicit):
     """Unique id object used as annotation on (content) objects.
     """
-    
+
     __implements__ = (
         IUniqueIdAnnotation,
     )
-    
+
     def __init__(self, obj, id):
         """See IUniqueIdAnnotation.
         """
         self._uid = None
         self.id = id
         setattr(obj, id, self)
-    
+
     def __call__(self):
         """See IUniqueIdAnnotation.
         """
         return self._uid
-        
+
     def getId(self):
         """See IUniqueIdAnnotation.
         """
         return self.id
-    
+
     def setUid(self, uid):
         """See IUniqueIdAnnotation.
         """
         self._uid = uid
-        
+
     def manage_afterClone(self, item):
         """See IUniqueIdAnnotation.
         """
@@ -71,10 +72,10 @@
         anno_tool = getToolByName(item, 'portal_uidannotation')
         if anno_tool.remove_on_clone:
             try:
-                delattr(item, self.id)
-            except KeyError, AttributeError:
+                delattr( aq_parent( aq_inner(self) ), self.id )
+            except (KeyError, AttributeError):
                 pass
-    
+
     def manage_beforeDelete(self, item, container):
         """See IUniqueIdAnnotation.
         """
@@ -83,12 +84,12 @@
         anno_tool = getToolByName(item, 'portal_uidannotation')
         if anno_tool.remove_on_add:
             self._cmf_uid_is_rename = True
-    
+
     def manage_afterAdd(self, item, container):
         """See IUniqueIdAnnotation.
         """
         # 'is_rename' is set if deletion was caused by a rename/move.
-        # The unique id is deleted only if the call is not part of 
+        # The unique id is deleted only if the call is not part of
         # a rename operation.
         # This way I the unique id gets deleted on imports.
         _is_rename = getattr(aq_base(self), '_cmf_uid_is_rename', None)
@@ -96,8 +97,8 @@
         if anno_tool.remove_on_add and anno_tool.remove_on_clone \
            and not _is_rename:
             try:
-                delattr(item, self.id)
-            except KeyError, AttributeError:
+                delattr( aq_parent( aq_inner(self) ), self.id )
+            except (KeyError, AttributeError):
                 pass
         if _is_rename is not None:
             del self._cmf_uid_is_rename
@@ -123,9 +124,9 @@
     id = 'portal_uidannotation'
     alternative_id = "portal_standard_uidannotation"
     meta_type = 'Unique Id Annotation Tool'
-    
+
     security = ClassSecurityInfo()
-    
+
     remove_on_add = True
     remove_on_clone = True
     _properties = (
@@ -134,7 +135,7 @@
     {'id': 'remove_on_clone', 'type': 'boolean', 'mode': 'w',
      'label': 'Remove the objects unique id on clone (CAUTION !!!)'},
     )
-    
+
     security.declarePrivate('__call__')
     def __call__(self, obj, id):
         """See IUniqueIdAnnotationManagement.



More information about the CMF-checkins mailing list