[CMF-checkins] CVS: CMF/CMFCore - CMFCatalogAware.py:1.17

Grégoire Weber zope.org at incept.ch
Thu Jan 1 20:05:53 EST 2004


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv30061

Modified Files:
	CMFCatalogAware.py 
Log Message:
manage_after*/before* hooks of callable opaque items now called also if marked with 'ICallableOpaqueItemWithHooks'


=== CMF/CMFCore/CMFCatalogAware.py 1.16 => 1.17 ===
--- CMF/CMFCore/CMFCatalogAware.py:1.16	Sun Dec  7 12:31:20 2003
+++ CMF/CMFCore/CMFCatalogAware.py	Thu Jan  1 20:05:52 2004
@@ -27,6 +27,7 @@
 from utils import _dtmldir
 from utils import getToolByName
 
+from interfaces.IOpaqueItems import ICallableOpaqueItemWithHooks
 
 class CMFCatalogAware(Base):
     """Mix-in for notifying portal_catalog and portal_workflow
@@ -117,14 +118,28 @@
             Return opaque items (subelements that are contained
             using something that is not an ObjectManager).
         """
-        # Since 'talkback' is the only opaque item on content
-        # right now, I will return that. Should be replaced with
-        # a list of tuples for every opaque item!
+        items = []
+        
+        # Call 'talkback' knowing that it is an opaque item.
+        # This will remain here as long as the discussion item does
+        # not implement ICallableOpaqueItemWithHooks (backwards 
+        # compatibility).
         if hasattr(aq_base(self), 'talkback'):
             talkback = self.talkback
             if talkback is not None:
-                return ((talkback.id, talkback),)
-        return ()
+                items.append((talkback.id, talkback))
+        
+        # Other opaque items than 'talkback' may have callable
+        # manage_after* and manage_before* hooks.
+        # Loop over all attributes and add those to 'items' 
+        # implementing 'ICallableOpaqueItemWithHooks'.
+        self_base = aq_base(self)
+        for name in self_base.__dict__.keys():
+            obj = getattr(self_base, name)
+            if ICallableOpaqueItemWithHooks.isImplementedBy(obj):
+                items.append((obj.id, obj))
+        
+        return tuple(items)
 
     security.declareProtected(AccessContentsInformation, 'opaqueIds')
     def opaqueIds(self):




More information about the CMF-checkins mailing list