[CMF-checkins] CVS: CMF/CMFCore - CMFCatalogAware.py:1.9 PortalContent.py:1.35

Florent Guillaume fg@nuxeo.com
19 Jul 2002 20:22:21 +0200


Yes, I thought of that after sending my mail. But it's just a few more
lines in CMFCatalogAware. I'll do that tonight if you think it's ok.

Florent

On Fri, 2002-07-19 at 20:02, Tres Seaver wrote:
> Hmmm, if you want OMs to be discussable, then you need to propagate
> afterAdd and beforeDelete to both 'objectValues' and 'opaqueValues';
> otherwise, "real" items won't do the Right Thing (TM).
> 
> 
> On Fri, 2002-07-19 at 13:50, Florent Guillaume wrote:
> > 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)
> 
> Tres.
> -- 
> ===============================================================
> Tres Seaver                                tseaver@zope.com
> Zope Corporation      "Zope Dealers"       http://www.zope.com
> 
> 
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com