[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/ - splitted up ICatalogAware

Yvo Schubbe y.2008 at wcm-solutions.de
Wed Apr 9 08:47:33 EDT 2008


Log message for revision 85187:
  - splitted up ICatalogAware

Changed:
  U   Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
  U   Products.CMFCore/trunk/Products/CMFCore/CMFCatalogAware.py
  U   Products.CMFCore/trunk/Products/CMFCore/event.zcml
  U   Products.CMFCore/trunk/Products/CMFCore/interfaces/_content.py
  U   Products.CMFCore/trunk/Products/CMFCore/testing.py

-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt	2008-04-09 12:04:09 UTC (rev 85186)
+++ Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt	2008-04-09 12:47:33 UTC (rev 85187)
@@ -12,7 +12,9 @@
       _setObject with suppress_events=True. CMF factory methods don't finish
       object creation, so they should not send the IObjectAddedEvent.
 
-    - interfaces: Added ICatalogAware for CMFCatalogAware methods.
+    - interfaces: Added new interfaces for CMFCatalogAware methods.
+      In the long run ICatalogAware, IWorkflowAware and IOpaqueItemManager will
+      become deprecated. Don't expect that CMF content always implements them.
 
     - setup handlers: All import and export steps are now registered globally.
 

Modified: Products.CMFCore/trunk/Products/CMFCore/CMFCatalogAware.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/CMFCatalogAware.py	2008-04-09 12:04:09 UTC (rev 85186)
+++ Products.CMFCore/trunk/Products/CMFCore/CMFCatalogAware.py	2008-04-09 12:47:33 UTC (rev 85187)
@@ -31,6 +31,8 @@
 
 from interfaces import ICallableOpaqueItem
 from interfaces import ICatalogAware
+from interfaces import IOpaqueItemManager
+from interfaces import IWorkflowAware
 from permissions import AccessContentsInformation
 from permissions import ManagePortal
 from permissions import ModifyPortalContent
@@ -46,20 +48,15 @@
     """Mix-in for notifying portal_catalog and portal_workflow
     """
 
-    implements(ICatalogAware)
+    implements(ICatalogAware, IWorkflowAware, IOpaqueItemManager)
 
     security = ClassSecurityInfo()
 
-    # The following methods can be overriden using inheritence so that
-    # it's possible to specifiy another catalog tool or workflow tool
-    # for a given content type
-
+    # The following method can be overriden using inheritence so that it's
+    # possible to specifiy another catalog tool for a given content type
     def _getCatalogTool(self):
         return getToolByName(self, 'portal_catalog', None)
 
-    def _getWorkflowTool(self):
-        return getToolByName(self, 'portal_workflow', None)
-
     #
     #   'ICatalogAware' interface methods
     #
@@ -123,11 +120,18 @@
                                   update_metadata=0, uid=brain_path)
             if s is None: ob._p_deactivate()
 
+    # The following method can be overriden using inheritence so that it's
+    # possible to specifiy another workflow tool for a given content type
+    def _getWorkflowTool(self):
+        return getToolByName(self, 'portal_workflow', None)
+
+    #
+    #   'IWorkflowAware' interface methods
+    #
     security.declarePrivate('notifyWorkflowCreated')
     def notifyWorkflowCreated(self):
+        """ Notify the workflow that the object was just created.
         """
-            Notify the workflow that self was just created.
-        """
         wftool = self._getWorkflowTool()
         if wftool is not None:
             wftool.notifyCreated(self)

Modified: Products.CMFCore/trunk/Products/CMFCore/event.zcml
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/event.zcml	2008-04-09 12:04:09 UTC (rev 85186)
+++ Products.CMFCore/trunk/Products/CMFCore/event.zcml	2008-04-09 12:47:33 UTC (rev 85187)
@@ -26,7 +26,7 @@
       />
 
   <subscriber
-      for=".interfaces.IDynamicType
+      for=".interfaces.IOpaqueItemManager
            zope.component.interfaces.IObjectEvent"
       handler=".CMFCatalogAware.dispatchToOpaqueItems"
       />

Modified: Products.CMFCore/trunk/Products/CMFCore/interfaces/_content.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/interfaces/_content.py	2008-04-09 12:04:09 UTC (rev 85186)
+++ Products.CMFCore/trunk/Products/CMFCore/interfaces/_content.py	2008-04-09 12:47:33 UTC (rev 85187)
@@ -518,7 +518,7 @@
 
 class ICatalogAware(Interface):
 
-    """ Interface for notifying portal_catalog and portal_workflow.
+    """ Interface for notifying the catalog tool.
     """
 
     def indexObject():
@@ -549,11 +549,23 @@
         reindexed, as there's no need to reindex its security twice.
         """
 
+
+class IWorkflowAware(Interface):
+
+    """ Interface for notifying the workflow tool.
+    """
+
     def notifyWorkflowCreated():
         """ Notify the workflow that the object was just created.
         """
 
 
+class IOpaqueItemManager(Interface):
+
+    """Interface for managing opaque items.
+    """
+
+
 #
 #   Folderish interfaces
 #

Modified: Products.CMFCore/trunk/Products/CMFCore/testing.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/testing.py	2008-04-09 12:04:09 UTC (rev 85186)
+++ Products.CMFCore/trunk/Products/CMFCore/testing.py	2008-04-09 12:47:33 UTC (rev 85187)
@@ -34,23 +34,26 @@
 
     def test_folder_interfaces(self):
         from webdav.interfaces import IWriteLock
-        from Products.CMFCore.interfaces import ICatalogAware
         from Products.CMFCore.interfaces import IDynamicType
         from Products.CMFCore.interfaces import IFolderish
         from Products.CMFCore.interfaces import IMutableMinimalDublinCore
 
-        verifyClass(ICatalogAware, self._getTargetClass())
         verifyClass(IDynamicType, self._getTargetClass())
         verifyClass(IFolderish, self._getTargetClass())
         verifyClass(IMutableMinimalDublinCore, self._getTargetClass())
         verifyClass(IWriteLock, self._getTargetClass())
 
+    def test_folder_extra_interfaces(self):
+        # in the long run this interface will become deprecated
+        from Products.CMFCore.interfaces import IOpaqueItemManager
 
+        verifyClass(IOpaqueItemManager, self._getTargetClass())
+
+
 class ConformsToContent:
 
     def test_content_interfaces(self):
         from Products.CMFCore.interfaces import ICatalogableDublinCore
-        from Products.CMFCore.interfaces import ICatalogAware
         from Products.CMFCore.interfaces import IContentish
         from Products.CMFCore.interfaces import IDublinCore
         from Products.CMFCore.interfaces import IDynamicType
@@ -58,14 +61,23 @@
         from Products.GenericSetup.interfaces import IDAVAware
 
         verifyClass(ICatalogableDublinCore, self._getTargetClass())
-        verifyClass(ICatalogAware, self._getTargetClass())
         verifyClass(IContentish, self._getTargetClass())
         verifyClass(IDAVAware, self._getTargetClass())
         verifyClass(IDublinCore, self._getTargetClass())
         verifyClass(IDynamicType, self._getTargetClass())
         verifyClass(IMutableDublinCore, self._getTargetClass())
 
+    def test_content_extra_interfaces(self):
+        # in the long run these interfaces will become deprecated
+        from Products.CMFCore.interfaces import ICatalogAware
+        from Products.CMFCore.interfaces import IOpaqueItemManager
+        from Products.CMFCore.interfaces import IWorkflowAware
 
+        verifyClass(ICatalogAware, self._getTargetClass())
+        verifyClass(IOpaqueItemManager, self._getTargetClass())
+        verifyClass(IWorkflowAware, self._getTargetClass())
+
+
 class BrowserLanguages(object):
 
     implements(IUserPreferredLanguages)



More information about the Checkins mailing list