[CMF-checkins] CVS: CMF/CMFCore - CMFCatalogAware.py:1.9 PortalContent.py:1.35
Florent Guillaume
fg@nuxeo.com
Fri, 19 Jul 2002 13:50:00 -0400
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv8774/CMFCore
Modified Files:
CMFCatalogAware.py PortalContent.py
Log Message:
Deal with the presence of opaque subitems (subitems that are not stored
using standard ObjectManager interface, typically talkbacks) in
PortalContent using opaqueItems/opaqueIds/opaqueValues instead of
objectValues & co.
Using objectValues for that purpose was wrong because:
- It's not really an ObjectManager.
- We'd like to have ObjectManagers that are also discussable.
=== CMF/CMFCore/CMFCatalogAware.py 1.8 => 1.9 ===
#
if aq_base(container) is not aq_base(self):
self.indexObject()
- #
- # Now let our "aspects" know we were added or moved.
- # For instance, talkbacks.
- #
- for item_id, subitem in self.objectItems():
- if hasattr(aq_base(subitem), 'manage_afterAdd'):
- subitem.manage_afterAdd(item, container)
+ # Recurse in opaque subitems (talkbacks for instance).
+ if hasattr(aq_base(self), 'opaqueValues'):
+ for subitem in self.opaqueValues():
+ if hasattr(aq_base(subitem), 'manage_afterAdd'):
+ subitem.manage_afterAdd(item, container)
def manage_afterClone(self, item):
"""
Add self to workflow, as we have just been cloned.
"""
self.notifyWorkflowCreated()
- #
- # Now let our "aspects" know we have been cloned.
- # For instance, talkbacks.
- #
- for item_id, subitem in self.objectItems():
- if hasattr(aq_base(subitem), 'manage_afterClone'):
- subitem.manage_afterClone(item)
+ # Recurse in opaque subitems.
+ if hasattr(aq_base(self), 'opaqueValues'):
+ for subitem in self.opaqueValues():
+ if hasattr(aq_base(subitem), 'manage_afterClone'):
+ subitem.manage_afterClone(item)
def manage_beforeDelete(self, item, container):
"""
@@ -88,15 +84,11 @@
#
if aq_base(container) is not aq_base(self):
self.unindexObject()
- #
- # Now let our "aspects" know we are going away.
- # For instance, talkbacks.
- #
- for item_id, subitem in self.objectItems():
- # Carefully avoid implicit acquisition of the
- # name "manage_beforeDelete"
- if hasattr(aq_base(subitem), 'manage_beforeDelete'):
- subitem.manage_beforeDelete(item, container)
+ # Recurse in opaque subitems.
+ if hasattr(aq_base(self), 'opaqueValues'):
+ for subitem in self.opaqueValues():
+ if hasattr(aq_base(subitem), 'manage_beforeDelete'):
+ subitem.manage_beforeDelete(item, container)
security.declarePrivate('notifyWorkflowCreated')
def notifyWorkflowCreated(self):
=== CMF/CMFCore/PortalContent.py 1.34 => 1.35 ===
'''
return self()
- # Overridden methods to support cataloging items that might
- # be stored in attributes unknown to the content object, such
- # as the DiscussionItemContainer "talkback"
+ # Methods to support items that might be stored in attributes
+ # unknown to the content object, such as the DiscussionItemContainer
+ # "talkback".
- security.declareProtected(AccessContentsInformation, 'objectItems')
- def objectItems(self):
+ security.declareProtected(AccessContentsInformation, 'opaqueItems')
+ def opaqueItems(self):
"""
- 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!
- """
- talkback = ( hasattr( aq_base( self ), 'talkback' ) and
- self.talkback or None )
- if talkback is not None:
- return ((talkback.id, talkback),)
- else:
- return ()
+ Returns 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!
+ if hasattr(aq_base(self), 'talkback'):
+ talkback = self.talkback
+ if talkback is not None:
+ return ((talkback.id, talkback),)
+ return ()
+
+ security.declareProtected(AccessContentsInformation, 'opaqueIds')
+ def opaqueIds(self):
+ """
+ Returns opaque ids (subelements that are contained
+ using something that is not an ObjectManager).
+ """
+ return [t[0] for t in self.opaqueItems()]
+
+ security.declareProtected(AccessContentsInformation, 'opaqueValues')
+ def opaqueValues(self):
+ """
+ Returns opaque values (subelements that are contained
+ using something that is not an ObjectManager).
+ """
+ return [t[1] for t in self.opaqueItems()]
InitializeClass(PortalContent)