[CMF-checkins] CVS: CMF/CMFDefault - DiscussionItem.py:1.37 Document.py:1.63 DublinCore.py:1.30 SkinnedFolder.py:1.17

Yvo Schubbe schubbe at web.de
Tue Dec 23 16:47:55 EST 2003


Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv21105/CMFDefault

Modified Files:
	DiscussionItem.py Document.py DublinCore.py SkinnedFolder.py 
Log Message:
Merged yuppie-collector025-branch:
- Creator element no longer depends on Ownership. (Collector #25)
- TypeInfo's _finishConstruction() now calls reindexObject().
- Removed WorkflowMethod wrapper of Document.setFormat().


=== CMF/CMFDefault/DiscussionItem.py 1.36 => 1.37 ===
--- CMF/CMFDefault/DiscussionItem.py:1.36	Sun Nov 16 04:43:18 2003
+++ CMF/CMFDefault/DiscussionItem.py	Tue Dec 23 16:47:24 2003
@@ -21,18 +21,15 @@
 from OFS.Traversable import Traversable
 from DateTime import DateTime
 
-from Products.CMFCore.CMFCorePermissions import View
 from Products.CMFCore.CMFCorePermissions import AccessContentsInformation
-from Products.CMFCore.CMFCorePermissions import ReplyToItem
 from Products.CMFCore.CMFCorePermissions import ManagePortal
+from Products.CMFCore.CMFCorePermissions import ReplyToItem
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.interfaces.Discussions import Discussable
+from Products.CMFCore.interfaces.Discussions import DiscussionResponse
 from Products.CMFCore.utils import getToolByName
-from Products.CMFCore.PortalContent import PortalContent
 
 from Document import Document
-from DublinCore import DefaultDublinCoreImpl
-
-from Products.CMFCore.interfaces.Discussions import DiscussionResponse
-from Products.CMFCore.interfaces.Discussions import Discussable
 
 
 factory_type_information = (
@@ -73,9 +70,9 @@
 
     Otherwise, same as addDocument
     """
-    
+
     if not description: description = title
-    text = scrubHTML(text) 
+    text = scrubHTML(text)
     item = DiscussionItem( id )
     item.title = title
     item.description = description
@@ -89,38 +86,36 @@
     if RESPONSE is not None:
         RESPONSE.redirect(self.absolute_url())
 
-    
-class DiscussionItem( Document
-                    , DefaultDublinCoreImpl
-                    ):
+
+class DiscussionItem(Document):
     """
         Class for content which is a response to other content.
     """
 
-    __implements__ = ( DiscussionResponse
-                     , PortalContent.__implements__
-                     , DefaultDublinCoreImpl.__implements__
-                     )
+    __implements__ = (DiscussionResponse, Document.__implements__)
 
     meta_type           = 'Discussion Item'
     portal_type         = 'Discussion Item'
     allow_discussion    = 1
-    creator             = 'unknown'
     in_reply_to         = None
     # XXX this is wrong, it precludes the use of a normal workflow.
     review_state        ='published'
 
     security = ClassSecurityInfo()
 
-    security.declareProtected(View, 'Creator')
-    def Creator( self ):
-        """
-            We need to return user who replied, rather than executable
-            owner.
-        """
-        #   XXX:  revisit if Creator becomes "real" attribute for stock DC.
-        return self.creator
-    
+    security.declareProtected(View, 'listCreators')
+    def listCreators(self):
+        """ List Dublin Core Creator elements - resource authors.
+        """
+        if not hasattr(self, 'creators'):
+            # for content created with CMF versions before 1.5
+            owner = self.getOwner()
+            if self.creator and self.creator != 'unknown':
+                self.creators = ( self.creator, )
+            else:
+                self.creators = ()
+        return self.creators
+
     #
     #   DiscussionResponse interface
     #
@@ -134,7 +129,7 @@
               - We are a "top-level" reply to a non-DiscussionItem piece
                 of content;  in this case, our 'in_reply_to' field will
                 be None.
-            
+
               - We are a nested reply;  in this case, our 'in_reply_to'
                 field will be the ID of the parent DiscussionItem.
         """
@@ -151,7 +146,7 @@
             self.in_reply_to = reply_to.getId()
         else:
             self.in_reply_to = None
-    
+
     security.declareProtected(View, 'parentsInThread')
     def parentsInThread( self, size=0 ):
         """
@@ -174,6 +169,7 @@
 
 InitializeClass( DiscussionItem )
 
+
 class DiscussionItemContainer( Persistent, Implicit, Traversable ):
     """
         Store DiscussionItem objects. Discussable content that
@@ -305,12 +301,12 @@
         item._edit( text_format=text_format, text=text )
 
         if Creator:
-            item.creator = Creator
+            item.__of__(self).addCreator(Creator)
 
         item.__of__( self ).indexObject()
 
         item.setReplyTo( self._getDiscussable() )
- 
+
         self._container[ id ] = item
 
         return id
@@ -340,10 +336,10 @@
             Test to see if there are any dicussion items
         """
         outer = self._getDiscussable( outer=1 )
-        if content_obj == outer: 
+        if content_obj == outer:
             return not not len( self._container )
         else:
-            return not not len( content_obj.talkback._getReplyResults() ) 
+            return not not len( content_obj.talkback._getReplyResults() )
 
     security.declareProtected(View, 'replyCount')
     def replyCount( self, content_obj ):
@@ -392,9 +388,9 @@
             Return this object's contents in a form suitable for inclusion
             as a quote in a response.
         """
- 
+
         return ""
-    
+
     #
     #   Utility methods
     #
@@ -409,7 +405,6 @@
             return outer
         parent = self._container[ in_reply_to ].__of__( aq_inner( self ) )
         return parent.__of__( outer )
-        
 
     security.declarePrivate( '_getDiscussable' )
     def _getDiscussable( self, outer=0 ):
@@ -441,5 +436,3 @@
         return result
 
 InitializeClass( DiscussionItemContainer )
-
-


=== CMF/CMFDefault/Document.py 1.62 => 1.63 ===
--- CMF/CMFDefault/Document.py:1.62	Mon Dec 15 11:20:22 2003
+++ CMF/CMFDefault/Document.py	Tue Dec 23 16:47:24 2003
@@ -24,7 +24,6 @@
 from Products.CMFCore.PortalContent import PortalContent
 from Products.CMFCore.CMFCorePermissions import View
 from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
-from Products.CMFCore.WorkflowCore import WorkflowAction
 from Products.CMFCore.utils import format_stx, keywordsplitter
 from DublinCore import DefaultDublinCoreImpl
 from utils import parseHeadersBody, formatRFC822Headers
@@ -46,7 +45,7 @@
   , 'aliases'        : {'(Default)':'document_view',
                         'view':'document_view',
                         'gethtml':'source_html'}
-  , 'actions'        : ( { 'id'            : 'view' 
+  , 'actions'        : ( { 'id'            : 'view'
                          , 'name'          : 'View'
                          , 'action': 'string:${object_url}/document_view'
                          , 'permissions'   : (View,)
@@ -338,7 +337,6 @@
             self.text_format = 'plain'
         else:
             self.text_format = 'structured-text'
-    setFormat = WorkflowAction(setFormat)
 
     ## FTP handlers
     security.declareProtected(ModifyPortalContent, 'PUT')


=== CMF/CMFDefault/DublinCore.py 1.29 => 1.30 ===
--- CMF/CMFDefault/DublinCore.py:1.29	Mon Dec 15 11:20:22 2003
+++ CMF/CMFDefault/DublinCore.py	Tue Dec 23 16:47:24 2003
@@ -27,6 +27,7 @@
 from Products.CMFCore.interfaces.DublinCore import CatalogableDublinCore
 from Products.CMFCore.interfaces.DublinCore import DublinCore
 from Products.CMFCore.interfaces.DublinCore import MutableDublinCore
+from Products.CMFCore.utils import getToolByName
 from Products.CMFCore.WorkflowCore import WorkflowAction
 
 from utils import tuplize, _dtmldir, semi_split
@@ -56,6 +57,7 @@
         now = DateTime()
         self.creation_date = now
         self.modification_date = now
+        self.creators = ()
         self._editMetadata( title
                           , subject
                           , description
@@ -77,13 +79,25 @@
 
     security.declarePrivate('notifyModified')
     def notifyModified(self):
+        """ Take appropriate action after the resource has been modified.
+
+        Update creators and modification_date.
         """
-        Take appropriate action after the resource has been modified.
-        For now, change the modification_date.
-        """
-        # XXX This could also store the id of the user doing modifications.
+        self.addCreator()
         self.setModificationDate()
 
+    security.declareProtected(ModifyPortalContent, 'addCreator')
+    def addCreator(self, creator=None):
+        """ Add creator to Dublin Core creators.
+        """
+        if creator is None:
+            mtool = getToolByName(self, 'portal_membership')
+            creator = mtool.getAuthenticatedMember().getId()
+
+        # call self.listCreators() to make sure self.creators exists
+        if creator and not creator in self.listCreators():
+            self.creators = self.creators + (creator, )
+
     # XXX Could this be simply protected by ModifyPortalContent ?
     security.declarePrivate('setModificationDate')
     def setModificationDate(self, modification_date=None):
@@ -105,16 +119,25 @@
         """
         return self.title
 
+    security.declareProtected(View, 'listCreators')
+    def listCreators(self):
+        """ List Dublin Core Creator elements - resource authors.
+        """
+        if not hasattr(self, 'creators'):
+            # for content created with CMF versions before 1.5
+            owner = self.getOwner()
+            if hasattr(owner, 'getId'):
+                self.creators = ( owner.getId(), )
+            else:
+                self.creators = ()
+        return self.creators
+
     security.declareProtected(View, 'Creator')
-    def Creator( self ):
-        """ Dublin Core Creator element - resource creator.
+    def Creator(self):
+        """ Dublin Core Creator element - resource author.
         """
-        # XXX: fixme using 'portal_membership' -- should iterate over
-        #       *all* owners
-        owner = self.getOwner()
-        if hasattr( owner, 'getId' ):
-            return owner.getId()
-        return 'No owner'
+        creators = self.listCreators()
+        return creators and creators[0] or ''
 
     security.declareProtected(View, 'Subject')
     def Subject( self ):
@@ -135,12 +158,17 @@
         # XXX: fixme using 'portal_metadata'
         return 'No publisher'
 
-    security.declareProtected(View, 'Contributors')
-    def Contributors( self ):
+    security.declareProtected(View, 'listContributors')
+    def listContributors(self):
         """ Dublin Core Contributor elements - resource collaborators.
         """
-        # XXX: fixme
         return self.contributors
+
+    security.declareProtected(View, 'Contributors')
+    def Contributors(self):
+        """ Deprecated alias of listContributors.
+        """
+        return self.listContributors()
 
     security.declareProtected(View, 'Date')
     def Date( self ):


=== CMF/CMFDefault/SkinnedFolder.py 1.16 => 1.17 ===
--- CMF/CMFDefault/SkinnedFolder.py:1.16	Mon Dec  1 08:55:43 2003
+++ CMF/CMFDefault/SkinnedFolder.py	Tue Dec 23 16:47:24 2003
@@ -22,10 +22,13 @@
 from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
 from Products.CMFCore.CMFCorePermissions import ListFolderContents
 from Products.CMFCore.CMFCorePermissions import ManageProperties
+from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
 from Products.CMFCore.CMFCorePermissions import View
 from Products.CMFCore.PortalFolder import PortalFolder
 from Products.CMFCore.utils import _getViewFor
 
+from DublinCore import DefaultDublinCoreImpl
+
 factory_type_information = (
   { 'id'             : 'Skinned Folder'
   , 'meta_type'      : 'Skinned Folder'
@@ -64,7 +67,7 @@
 
 
 class SkinnedFolder(CMFCatalogAware, PortalFolder):
-    """
+    """ Skinned Folder class. 
     """
     meta_type = 'Skinned Folder'
 
@@ -87,16 +90,29 @@
 
     index_html = None  # This special value informs ZPublisher to use __call__
 
-    security.declareProtected(View, 'Creator')
-    def Creator( self ):
-        """
-            Return the ID of our owner.
+    # XXX: maybe we should subclass from DefaultDublinCoreImpl or refactor it
+
+    security.declarePrivate('notifyModified')
+    def notifyModified(self):
+        """ Take appropriate action after the resource has been modified.
+
+        Update creators.
         """
-        return self.getOwner( info=1 )[1]
+        self.addCreator()
+
+    security.declareProtected(ModifyPortalContent, 'addCreator')
+    addCreator = DefaultDublinCoreImpl.addCreator.im_func
+
+    security.declareProtected(View, 'listCreators')
+    listCreators = DefaultDublinCoreImpl.listCreators.im_func
+
+    security.declareProtected(View, 'Creator')
+    Creator = DefaultDublinCoreImpl.Creator.im_func
 
     # We derive from CMFCatalogAware first, so we are cataloged too.
 
 InitializeClass( SkinnedFolder )
+
 
 def addSkinnedFolder( self, id, title='', description='', REQUEST=None ):
     """




More information about the CMF-checkins mailing list