[CMF-checkins] SVN: CMF/trunk/C - added IFactory utilities for all content classes

Yvo Schubbe y.2006_ at wcm-solutions.de
Thu Jun 1 05:25:46 EDT 2006


Log message for revision 68426:
  - added IFactory utilities for all content classes
  - added 'handleFavoriteAddedEvent' subscriber
  - modernized registration of all content classes
  - changed all profiles to use the new content factories

Changed:
  U   CMF/trunk/CHANGES.txt
  U   CMF/trunk/CMFCalendar/Event.py
  U   CMF/trunk/CMFCalendar/__init__.py
  U   CMF/trunk/CMFCalendar/configure.zcml
  U   CMF/trunk/CMFCalendar/profiles/default/types/Event.xml
  U   CMF/trunk/CMFDefault/Document.py
  U   CMF/trunk/CMFDefault/Favorite.py
  U   CMF/trunk/CMFDefault/File.py
  U   CMF/trunk/CMFDefault/Image.py
  U   CMF/trunk/CMFDefault/Link.py
  U   CMF/trunk/CMFDefault/NewsItem.py
  U   CMF/trunk/CMFDefault/SkinnedFolder.py
  U   CMF/trunk/CMFDefault/__init__.py
  U   CMF/trunk/CMFDefault/configure.zcml
  A   CMF/trunk/CMFDefault/content.zcml
  U   CMF/trunk/CMFDefault/profiles/default/types/Document.xml
  U   CMF/trunk/CMFDefault/profiles/default/types/Favorite.xml
  U   CMF/trunk/CMFDefault/profiles/default/types/File.xml
  U   CMF/trunk/CMFDefault/profiles/default/types/Image.xml
  U   CMF/trunk/CMFDefault/profiles/default/types/Link.xml
  U   CMF/trunk/CMFDefault/profiles/default/types/News_Item.xml
  U   CMF/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py
  U   CMF/trunk/CMFDefault/tests/test_DiscussionReply.py
  U   CMF/trunk/CMFDefault/tests/test_Image.py
  U   CMF/trunk/CMFDefault/tests/test_Portal.py
  U   CMF/trunk/CMFTopic/Topic.py
  U   CMF/trunk/CMFTopic/__init__.py
  U   CMF/trunk/CMFTopic/configure.zcml
  U   CMF/trunk/CMFTopic/profiles/default/types/Topic.xml

-=-
Modified: CMF/trunk/CHANGES.txt
===================================================================
--- CMF/trunk/CHANGES.txt	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CHANGES.txt	2006-06-01 09:25:43 UTC (rev 68426)
@@ -2,6 +2,9 @@
 
   New Features
 
+    - Content: Added IFactory utilities for all content classes.
+      They are now used by default instead of the old constructor methods.
+
     - FactoryTypeInformation: Added support for Zope3 style factories.
       If the 'product' property of a type info instance is empty the 'factory'
       property is interpreted as an IFactory name.
@@ -12,6 +15,12 @@
 
   Others
 
+    - Content: All content classes are now registered by ZCML.
+      ContentInit is still used to register oldstyle constructors.
+
+    - Favorite: Added 'handleFavoriteAddedEvent' subscriber.
+      This replaces the 'manage_afterAdd' hook and some code in 'addFavorite'.
+
     - CMFCatalogAware: Added 'handleObjectEvent' subscriber.
       This replaces the deprecated 'manage_afterAdd', 'manage_afterClone' and
       'manage_beforeDelete' hooks.

Modified: CMF/trunk/CMFCalendar/Event.py
===================================================================
--- CMF/trunk/CMFCalendar/Event.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFCalendar/Event.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -15,23 +15,22 @@
 $Id$
 """
 
+import transaction
 from AccessControl import ClassSecurityInfo
 from DateTime import DateTime
 from Globals import InitializeClass
-import transaction
+from zope.component.factory import Factory
 from zope.interface import implements
 
 from Products.CMFCore.PortalContent import PortalContent
 from Products.CMFCore.utils import contributorsplitter
 from Products.CMFCore.utils import keywordsplitter
-
 from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
 from Products.CMFDefault.utils import bodyfinder
 from Products.CMFDefault.utils import formatRFC822Headers
 from Products.CMFDefault.utils import html_headcheck
 from Products.CMFDefault.utils import parseHeadersBody
 from Products.CMFDefault.utils import SimpleHTMLParser
-
 from Products.GenericSetup.interfaces import IDAVAware
 
 from exceptions import ResourceLockedError
@@ -95,8 +94,6 @@
     """Events are objects for the Calendar topical query.
     """
 
-    meta_type='CMF Event'
-
     # Declarative security
     security = ClassSecurityInfo()
     security.declareObjectProtected(View)
@@ -372,8 +369,8 @@
         return hdrlist
 
     ## FTP handlers
-    security.declareProtected(ModifyPortalContent, 'PUT')
 
+    security.declareProtected(ModifyPortalContent, 'PUT')
     def PUT(self, REQUEST, RESPONSE):
         """ Handle HTTP (and presumably FTP?) PUT requests """
         self.dav__init(REQUEST, RESPONSE)
@@ -421,3 +418,5 @@
         return len(self.manage_FTPget())
 
 InitializeClass(Event)
+
+EventFactory = Factory(Event)

Modified: CMF/trunk/CMFCalendar/__init__.py
===================================================================
--- CMF/trunk/CMFCalendar/__init__.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFCalendar/__init__.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -38,10 +38,6 @@
 
 z_bases = utils.initializeBasesPhase1( contentClasses, this_module )
 
-# This is used by a script (external method) that can be run
-# to set up Events in an existing CMF Site instance.
-event_globals=globals()
-
 # Make the skins available as DirectoryViews
 registerDirectory('skins', globals())
 
@@ -50,10 +46,12 @@
                    ).initialize( context )
 
     utils.initializeBasesPhase2( z_bases, context )
-    utils.ContentInit( 'CMF Event'
-                     , content_types = contentClasses
-                     , permission = AddPortalContent
-                     , extra_constructors = contentConstructors
+
+    # BBB: register oldstyle constructors
+    utils.ContentInit( 'CMF Calendar Content'
+                     , content_types=()
+                     , permission=AddPortalContent
+                     , extra_constructors=contentConstructors
                      ).initialize( context )
 
     profile_registry.registerProfile('default',

Modified: CMF/trunk/CMFCalendar/configure.zcml
===================================================================
--- CMF/trunk/CMFCalendar/configure.zcml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFCalendar/configure.zcml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -1,9 +1,23 @@
 <configure
-    xmlns="http://namespaces.zope.org/zope">
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:five="http://namespaces.zope.org/five">
 
   <!-- Load CMFDefault.skin first, we use the layer named "cmf" it defines -->
   <include package="Products.CMFDefault.skin"/>
 
   <include package=".browser"/>
 
+  <!-- Event -->
+
+  <five:registerClass
+      class=".Event.Event"
+      meta_type="CMF Event"
+      permission="cmf.AddPortalContent"
+      />
+
+  <utility
+      component=".Event.EventFactory"
+      name="cmf.event"
+      />
+
 </configure>

Modified: CMF/trunk/CMFCalendar/profiles/default/types/Event.xml
===================================================================
--- CMF/trunk/CMFCalendar/profiles/default/types/Event.xml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFCalendar/profiles/default/types/Event.xml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -7,8 +7,8 @@
     i18n:translate="">Events are objects for use in Calendar topical queries on the catalog.</property>
  <property name="content_icon">event_icon.gif</property>
  <property name="content_meta_type">CMF Event</property>
- <property name="product">CMFCalendar</property>
- <property name="factory">addEvent</property>
+ <property name="product"></property>
+ <property name="factory">cmf.event</property>
  <property name="immediate_view">event_edit_form</property>
  <property name="global_allow">True</property>
  <property name="filter_content_types">True</property>

Modified: CMF/trunk/CMFDefault/Document.py
===================================================================
--- CMF/trunk/CMFDefault/Document.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/Document.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -23,6 +23,7 @@
 from Globals import DTMLFile
 from Globals import InitializeClass
 from StructuredText.StructuredText import HTML
+from zope.component.factory import Factory
 from zope.interface import implements
 
 from Products.CMFCore.PortalContent import PortalContent
@@ -65,7 +66,6 @@
                       PortalContent.__implements__,
                       DefaultDublinCoreImpl.__implements__)
 
-    meta_type = 'Document'
     effective_date = expiration_date = None
     cooked_text = text = text_format = ''
     _size = 0
@@ -428,3 +428,5 @@
         return self._size
 
 InitializeClass(Document)
+
+DocumentFactory = Factory(Document)

Modified: CMF/trunk/CMFDefault/Favorite.py
===================================================================
--- CMF/trunk/CMFDefault/Favorite.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/Favorite.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -20,6 +20,9 @@
 from Globals import InitializeClass
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_base
+from zope.app.container.interfaces import IObjectAddedEvent
+from zope.component import adapter
+from zope.component.factory import Factory
 from zope.interface import implements
 
 from Products.CMFCore.utils import getToolByName
@@ -34,13 +37,8 @@
 def addFavorite(self, id, title='', remote_url='', description=''):
     """Add a Favorite.
     """
-    portal_url = getToolByName(self, 'portal_url')
-    portal_obj = portal_url.getPortalObject()
-    content_obj = portal_obj.restrictedTraverse( remote_url )
-    relUrl = portal_url.getRelativeUrl( content_obj )
-    
-    o=Favorite( id, title, relUrl, description )
-    self._setObject(id,o)
+    o = Favorite(id, title, remote_url, description)
+    self._setObject(id, o)
 
 
 class Favorite(Link):
@@ -51,8 +49,6 @@
     implements(IMutableFavorite, IFavorite)
     __implements__ = Link.__implements__ # redundant, but explicit
 
-    meta_type='Favorite'
-
     security = ClassSecurityInfo()
 
     def __init__( self
@@ -67,19 +63,6 @@
         self.remote_url=remote_url
         self.description = description
         
-    def manage_afterAdd(self, item, container):
-        """Intercept after favorite has beeing added.
-        
-        The tools are not reachable in '__init__' because 'self' is 
-        not yet wrapped at this time. That's why the after add hook
-        has to be intercepted.
-        """
-        # save unique id of favorite
-        self.remote_uid = self._getUidByUrl()
-        
-        # do the usual stuff
-        Link.manage_afterAdd(self, item, container)
-        
     def _getUidByUrl(self):
         """Registers and returns the uid of the remote object if
         the unique id handler tool is available.
@@ -185,3 +168,13 @@
         self.remote_uid = self._getUidByUrl()
 
 InitializeClass(Favorite)
+
+FavoriteFactory = Factory(Favorite)
+
+
+ at adapter(IFavorite, IObjectAddedEvent)
+def handleFavoriteAddedEvent(obj, event):
+    """Event subscriber.
+    """
+    if obj.remote_url:
+        obj.edit(obj.remote_url)

Modified: CMF/trunk/CMFDefault/File.py
===================================================================
--- CMF/trunk/CMFDefault/File.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/File.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -18,8 +18,9 @@
 """
 
 import OFS.Image
+from AccessControl import ClassSecurityInfo
 from Globals import InitializeClass
-from AccessControl import ClassSecurityInfo
+from zope.component.factory import Factory
 from zope.interface import implements
 
 from Products.CMFCore.PortalContent import PortalContent
@@ -79,7 +80,6 @@
                      , DefaultDublinCoreImpl.__implements__
                      )
     
-    meta_type='Portal File'
     effective_date = expiration_date = None
     _isDiscussable = 1
     icon = PortalContent.icon
@@ -199,3 +199,5 @@
         self.reindexObject()
 
 InitializeClass(File)
+
+FileFactory = Factory(File)

Modified: CMF/trunk/CMFDefault/Image.py
===================================================================
--- CMF/trunk/CMFDefault/Image.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/Image.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -19,6 +19,7 @@
 import OFS.Image
 from AccessControl import ClassSecurityInfo
 from Globals import InitializeClass
+from zope.component.factory import Factory
 from zope.interface import implements
 
 from Products.CMFCore.PortalContent import PortalContent
@@ -77,7 +78,6 @@
                      , DefaultDublinCoreImpl.__implements__
                      )
     
-    meta_type='Portal Image'
     effective_date = expiration_date = None
     _isDiscussable = 1
     icon = PortalContent.icon
@@ -187,3 +187,5 @@
         self.reindexObject()
 
 InitializeClass(Image)
+
+ImageFactory = Factory(Image)

Modified: CMF/trunk/CMFDefault/Link.py
===================================================================
--- CMF/trunk/CMFDefault/Link.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/Link.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -21,6 +21,7 @@
 from AccessControl import ClassSecurityInfo
 from Globals import DTMLFile
 from Globals import InitializeClass
+from zope.component.factory import Factory
 from zope.interface import implements
 
 from Products.CMFCore.PortalContent import PortalContent
@@ -61,7 +62,6 @@
                      , DefaultDublinCoreImpl.__implements__
                      )
 
-    meta_type = 'Link'
     URL_FORMAT = format = 'text/url'
     effective_date = expiration_date = None
     _isDiscussable = 1
@@ -201,3 +201,5 @@
         return len(self.manage_FTPget())
 
 InitializeClass(Link)
+
+LinkFactory = Factory(Link)

Modified: CMF/trunk/CMFDefault/NewsItem.py
===================================================================
--- CMF/trunk/CMFDefault/NewsItem.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/NewsItem.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -17,6 +17,7 @@
 
 from AccessControl import ClassSecurityInfo
 from Globals import InitializeClass
+from zope.component.factory import Factory
 from zope.interface import implements
 
 from Document import Document
@@ -52,7 +53,6 @@
     implements(IMutableNewsItem, INewsItem)
     __implements__ = Document.__implements__  # redundant, but explicit
 
-    meta_type='News Item'
     text_format = 'html'
 
     security = ClassSecurityInfo()
@@ -68,3 +68,5 @@
         Document.edit( self, text_format, text )
 
 InitializeClass(NewsItem)
+
+NewsItemFactory = Factory(NewsItem)

Modified: CMF/trunk/CMFDefault/SkinnedFolder.py
===================================================================
--- CMF/trunk/CMFDefault/SkinnedFolder.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/SkinnedFolder.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -17,6 +17,7 @@
 
 from AccessControl import ClassSecurityInfo
 from Globals import InitializeClass
+from zope.component.factory import Factory
 from zope.interface import implements
 
 from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
@@ -35,8 +36,6 @@
 
     implements(IContentish)
 
-    meta_type = 'Skinned Folder'
-
     security = ClassSecurityInfo()
 
     manage_options = PortalFolder.manage_options
@@ -76,6 +75,7 @@
 
 InitializeClass(SkinnedFolder)
 
+SkinnedFolderFactory = Factory(SkinnedFolder)
 
 def addSkinnedFolder( self, id, title='', description='', REQUEST=None ):
     """

Modified: CMF/trunk/CMFDefault/__init__.py
===================================================================
--- CMF/trunk/CMFDefault/__init__.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/__init__.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -15,6 +15,8 @@
 $Id$
 """
 
+import sys
+
 from Products.CMFCore.DirectoryView import registerDirectory
 from Products.CMFCore.interfaces import ISiteRoot
 from Products.CMFCore.utils import initializeBasesPhase1
@@ -82,14 +84,11 @@
         , SyndicationTool.SyndicationTool
         )
 
-import sys
 this_module = sys.modules[ __name__ ]
 
 z_bases = initializeBasesPhase1( bases, this_module )
 z_tool_bases = initializeBasesPhase1( tools, this_module )
 
-cmfdefault_globals=globals()
-
 # Make the skins available as DirectoryViews.
 registerDirectory('skins', globals())
 registerDirectory('help', globals())
@@ -104,8 +103,9 @@
             , icon='tool.gif'
             ).initialize( context )
 
+    # BBB: register oldstyle constructors
     ContentInit( 'CMF Default Content'
-               , content_types=contentClasses
+               , content_types=()
                , permission=AddPortalContent
                , extra_constructors=contentConstructors
                ).initialize( context )

Modified: CMF/trunk/CMFDefault/configure.zcml
===================================================================
--- CMF/trunk/CMFDefault/configure.zcml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/configure.zcml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -5,4 +5,6 @@
 
   <include package=".browser"/>
 
+  <include file="content.zcml"/>
+
 </configure>

Added: CMF/trunk/CMFDefault/content.zcml
===================================================================
--- CMF/trunk/CMFDefault/content.zcml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/content.zcml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -0,0 +1,98 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:five="http://namespaces.zope.org/five">
+
+  <!-- Document -->
+
+  <five:registerClass
+      class=".Document.Document"
+      meta_type="Document"
+      permission="cmf.AddPortalContent"
+      />
+
+  <utility
+      component=".Document.DocumentFactory"
+      name="cmf.document"
+      />
+
+  <!-- Favorite -->
+
+  <five:registerClass
+      class=".Favorite.Favorite"
+      meta_type="Favorite"
+      permission="cmf.AddPortalContent"
+      />
+
+  <utility
+      component=".Favorite.FavoriteFactory"
+      name="cmf.favorite"
+      />
+
+  <subscriber handler=".Favorite.handleFavoriteAddedEvent" />
+
+  <!-- File -->
+
+  <five:registerClass
+      class=".File.File"
+      meta_type="Portal File"
+      permission="cmf.AddPortalContent"
+      />
+
+  <utility
+      component=".File.FileFactory"
+      name="cmf.file"
+      />
+
+  <!-- Image -->
+
+  <five:registerClass
+      class=".Image.Image"
+      meta_type="Portal Image"
+      permission="cmf.AddPortalContent"
+      />
+
+  <utility
+      component=".Image.ImageFactory"
+      name="cmf.image"
+      />
+
+  <!-- Link -->
+
+  <five:registerClass
+      class=".Link.Link"
+      meta_type="Link"
+      permission="cmf.AddPortalContent"
+      />
+
+  <utility
+      component=".Link.LinkFactory"
+      name="cmf.link"
+      />
+
+  <!-- NewsItem -->
+
+  <five:registerClass
+      class=".NewsItem.NewsItem"
+      meta_type="News Item"
+      permission="cmf.AddPortalContent"
+      />
+
+  <utility
+      component=".NewsItem.NewsItemFactory"
+      name="cmf.newsitem"
+      />
+
+  <!-- SkinnedFolder -->
+
+  <five:registerClass
+      class=".SkinnedFolder.SkinnedFolder"
+      meta_type="Skinned Folder"
+      permission="cmf.AddPortalContent"
+      />
+
+  <utility
+      component=".SkinnedFolder.SkinnedFolderFactory"
+      name="cmf.folder.skinned"
+      />
+
+</configure>


Property changes on: CMF/trunk/CMFDefault/content.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: CMF/trunk/CMFDefault/profiles/default/types/Document.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Document.xml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/profiles/default/types/Document.xml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -7,8 +7,8 @@
   They may also contain HTML, or "plain" text.</property>
  <property name="content_icon">document_icon.gif</property>
  <property name="content_meta_type">Document</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addDocument</property>
+ <property name="product"></property>
+ <property name="factory">cmf.document</property>
  <property name="immediate_view">metadata_edit_form</property>
  <property name="global_allow">True</property>
  <property name="filter_content_types">True</property>

Modified: CMF/trunk/CMFDefault/profiles/default/types/Favorite.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Favorite.xml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/profiles/default/types/Favorite.xml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -6,8 +6,8 @@
     i18n:translate="">A Favorite is a Link to an intra-portal resource.</property>
  <property name="content_icon">link_icon.gif</property>
  <property name="content_meta_type">Favorite</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addFavorite</property>
+ <property name="product"></property>
+ <property name="factory">cmf.favorite</property>
  <property name="immediate_view">metadata_edit_form</property>
  <property name="global_allow">True</property>
  <property name="filter_content_types">True</property>

Modified: CMF/trunk/CMFDefault/profiles/default/types/File.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/File.xml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/profiles/default/types/File.xml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -6,8 +6,8 @@
     i18n:translate="">File objects can contain arbitrary downloadable files.</property>
  <property name="content_icon">file_icon.gif</property>
  <property name="content_meta_type">Portal File</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addFile</property>
+ <property name="product"></property>
+ <property name="factory">cmf.file</property>
  <property name="immediate_view">metadata_edit_form</property>
  <property name="global_allow">True</property>
  <property name="filter_content_types">True</property>

Modified: CMF/trunk/CMFDefault/profiles/default/types/Image.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Image.xml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/profiles/default/types/Image.xml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -6,8 +6,8 @@
     i18n:translate="">Image objects can be embedded in Portal documents.</property>
  <property name="content_icon">image_icon.gif</property>
  <property name="content_meta_type">Portal Image</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addImage</property>
+ <property name="product"></property>
+ <property name="factory">cmf.image</property>
  <property name="immediate_view">metadata_edit_form</property>
  <property name="global_allow">True</property>
  <property name="filter_content_types">True</property>

Modified: CMF/trunk/CMFDefault/profiles/default/types/Link.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Link.xml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/profiles/default/types/Link.xml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -6,8 +6,8 @@
     i18n:translate="">Link items are annotated URLs.</property>
  <property name="content_icon">link_icon.gif</property>
  <property name="content_meta_type">Link</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addLink</property>
+ <property name="product"></property>
+ <property name="factory">cmf.link</property>
  <property name="immediate_view">metadata_edit_form</property>
  <property name="global_allow">True</property>
  <property name="filter_content_types">True</property>

Modified: CMF/trunk/CMFDefault/profiles/default/types/News_Item.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/News_Item.xml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/profiles/default/types/News_Item.xml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -7,8 +7,8 @@
   an optional description.</property>
  <property name="content_icon">newsitem_icon.gif</property>
  <property name="content_meta_type">News Item</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addNewsItem</property>
+ <property name="product"></property>
+ <property name="factory">cmf.newsitem</property>
  <property name="immediate_view">metadata_edit_form</property>
  <property name="global_allow">True</property>
  <property name="filter_content_types">True</property>

Modified: CMF/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -3,7 +3,6 @@
 from Products.CMFCore.utils import getToolByName
 
 mtool = getToolByName(script, 'portal_membership')
-utool = getToolByName(script, 'portal_url')
 
 home = mtool.getHomeFolder()
 if not hasattr(home, 'Favorites'):
@@ -12,7 +11,7 @@
 
 f_id = 'fav_' + str( int( context.ZopeTime() ) )
 f_title = context.TitleOrId()
-f_url = utool.getRelativeUrl(context)
+f_url = context.absolute_url()
 favorites.invokeFactory('Favorite', id=f_id, title=f_title, remote_url=f_url)
 
 context.setRedirect(context, 'object/view')

Modified: CMF/trunk/CMFDefault/tests/test_DiscussionReply.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_DiscussionReply.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/tests/test_DiscussionReply.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -36,6 +36,7 @@
         zcml.load_config('permissions.zcml', Products.Five)
         zcml.load_config('configure.zcml', Products.GenericSetup)
         zcml.load_config('configure.zcml', Products.CMFCore)
+        zcml.load_config('configure.zcml', Products.CMFDefault)
         zcml.load_config('configure.zcml', Products.DCWorkflow)
         try:
             factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite

Modified: CMF/trunk/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Image.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/tests/test_Image.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -114,6 +114,7 @@
         zcml.load_config('permissions.zcml', Products.Five)
         zcml.load_config('configure.zcml', Products.GenericSetup)
         zcml.load_config('configure.zcml', Products.CMFCore)
+        zcml.load_config('configure.zcml', Products.CMFDefault)
         zcml.load_config('configure.zcml', Products.DCWorkflow)
         try:
             factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite

Modified: CMF/trunk/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Portal.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFDefault/tests/test_Portal.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -54,6 +54,7 @@
         zcml.load_config('permissions.zcml', Products.Five)
         zcml.load_config('configure.zcml', Products.GenericSetup)
         zcml.load_config('configure.zcml', Products.CMFCore)
+        zcml.load_config('configure.zcml', Products.CMFDefault)
         zcml.load_config('configure.zcml', Products.DCWorkflow)
 
     def tearDown(self):

Modified: CMF/trunk/CMFTopic/Topic.py
===================================================================
--- CMF/trunk/CMFTopic/Topic.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFTopic/Topic.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -18,6 +18,7 @@
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_parent, aq_inner
 from Globals import InitializeClass
+from zope.component.factory import Factory
 from zope.interface import implements
 
 from Products.CMFDefault.SkinnedFolder import SkinnedFolder
@@ -52,8 +53,6 @@
 
     implements(IMutableTopic, ITopic)
 
-    meta_type='Portal Topic'
-
     security = ClassSecurityInfo()
     security.declareObjectProtected(View)
 
@@ -216,3 +215,5 @@
         return tuple( result )
 
 InitializeClass(Topic)
+
+TopicFactory = Factory(Topic)

Modified: CMF/trunk/CMFTopic/__init__.py
===================================================================
--- CMF/trunk/CMFTopic/__init__.py	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFTopic/__init__.py	2006-06-01 09:25:43 UTC (rev 68426)
@@ -41,10 +41,6 @@
 for base in bases:
     createZClassForBase( base, this_module )
 
-# This is used by a script (external method) that can be run
-# to set up Topics in an existing CMF Site instance.
-topic_globals = globals()
-
 # Make the skins available as DirectoryViews
 registerDirectory( 'skins', globals() )
 
@@ -53,11 +49,11 @@
     context.registerHelpTitle( 'CMF Topic Help' )
     context.registerHelp( directory='help' )
 
-    # CMF Initializers
-    ContentInit( 'CMF Topic Objects'
-               , content_types = (Topic.Topic,)
-               , permission = AddTopics
-               , extra_constructors = (Topic.addTopic,)
+    # BBB: register oldstyle constructors
+    ContentInit( 'CMF Topic Content'
+               , content_types=()
+               , permission=AddTopics
+               , extra_constructors=(Topic.addTopic,)
                ).initialize( context )
 
     profile_registry.registerProfile('default',

Modified: CMF/trunk/CMFTopic/configure.zcml
===================================================================
--- CMF/trunk/CMFTopic/configure.zcml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFTopic/configure.zcml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -1,7 +1,28 @@
 <configure
     xmlns="http://namespaces.zope.org/zope"
-    >
+    xmlns:five="http://namespaces.zope.org/five"
+    i18n_domain="cmf_default">
 
+  <permission
+      id="cmf.AddPortalTopics"
+      title="Add portal topics"
+      />
+
+  <!-- Topic -->
+
+  <five:registerClass
+      class=".Topic.Topic"
+      meta_type="Portal Topic"
+      permission="cmf.AddPortalTopics"
+      />
+
+  <utility
+      component=".Topic.TopicFactory"
+      name="cmf.topic"
+      />
+
+  <!-- exportimport -->
+
   <adapter
       factory=".exportimport.TopicExportImport"
       provides="Products.GenericSetup.interfaces.IFilesystemExporter"

Modified: CMF/trunk/CMFTopic/profiles/default/types/Topic.xml
===================================================================
--- CMF/trunk/CMFTopic/profiles/default/types/Topic.xml	2006-06-01 08:42:41 UTC (rev 68425)
+++ CMF/trunk/CMFTopic/profiles/default/types/Topic.xml	2006-06-01 09:25:43 UTC (rev 68426)
@@ -6,8 +6,8 @@
     i18n:translate="">Topics are canned queries for organizing content with up to date queries into the catalog.</property>
  <property name="content_icon">topic_icon.gif</property>
  <property name="content_meta_type">Portal Topic</property>
- <property name="product">CMFTopic</property>
- <property name="factory">addTopic</property>
+ <property name="product"></property>
+ <property name="factory">cmf.topic</property>
  <property name="immediate_view">topic_edit_form</property>
  <property name="global_allow">True</property>
  <property name="filter_content_types">True</property>



More information about the CMF-checkins mailing list