[CMF-checkins] SVN: CMF/branches/2.1/ Issue #440: remove antique usage of marker attributes in favor of interfaces, w/ BBB.

Tres Seaver tseaver at palladion.com
Mon Apr 9 17:23:44 EDT 2007


Log message for revision 74063:
  Issue #440:  remove antique usage of marker attributes in favor of interfaces, w/ BBB.

Changed:
  U   CMF/branches/2.1/CHANGES.txt
  U   CMF/branches/2.1/CMFCore/ActionInformation.py
  U   CMF/branches/2.1/CMFCore/DirectoryView.py
  U   CMF/branches/2.1/CMFCore/DiscussionTool.py
  U   CMF/branches/2.1/CMFCore/PortalContent.py
  U   CMF/branches/2.1/CMFCore/PortalFolder.py
  U   CMF/branches/2.1/CMFCore/PortalObject.py
  U   CMF/branches/2.1/CMFCore/TypesTool.py
  U   CMF/branches/2.1/CMFCore/WorkflowTool.py
  U   CMF/branches/2.1/CMFCore/tests/base/dummy.py
  U   CMF/branches/2.1/CMFCore/tests/test_WorkflowTool.py
  U   CMF/branches/2.1/CMFDefault/DefaultWorkflow.py
  U   CMF/branches/2.1/CMFDefault/Document.py
  U   CMF/branches/2.1/CMFDefault/File.py
  U   CMF/branches/2.1/CMFDefault/Image.py
  U   CMF/branches/2.1/CMFDefault/Link.py
  U   CMF/branches/2.1/DCWorkflow/DCWorkflow.py
  U   CMF/branches/2.1/DCWorkflow/Expression.py

-=-
Modified: CMF/branches/2.1/CHANGES.txt
===================================================================
--- CMF/branches/2.1/CHANGES.txt	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CHANGES.txt	2007-04-09 21:23:43 UTC (rev 74063)
@@ -2,6 +2,10 @@
 
   Bug Fixes
 
+    - Remove antique usage of marker attributes in favor of interfaces,
+      leaving BBB behind for places potentially affecting third-party code.
+      (http://www.zope.org/Collectors/CMF/440)
+
     - Fixed DST-driven test breakage in CMFCalendar by adding an optional
       'zone' argument to the DublineCore methods which return string
       rednitions of date metadata.

Modified: CMF/branches/2.1/CMFCore/ActionInformation.py
===================================================================
--- CMF/branches/2.1/CMFCore/ActionInformation.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFCore/ActionInformation.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -253,7 +253,6 @@
 
     implements(IAction)
 
-    _isActionInformation = 1
     __allow_access_to_unprotected_subobjects__ = 1
 
     security = ClassSecurityInfo()

Modified: CMF/branches/2.1/CMFCore/DirectoryView.py
===================================================================
--- CMF/branches/2.1/CMFCore/DirectoryView.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFCore/DirectoryView.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -36,7 +36,7 @@
 from FSMetadata import FSMetadata
 from FSObject import BadFile
 from interfaces import IDirectoryView
-from permissions import AccessContentsInformation
+from permissions import AccessContentsInformation as ACI
 from permissions import ManagePortal
 from utils import _dtmldir
 from utils import normalize
@@ -519,7 +519,6 @@
 
     meta_type = 'Filesystem Directory View'
     all_meta_types = ()
-    _isDirectoryView = 1
 
     security = ClassSecurityInfo()
 
@@ -552,14 +551,24 @@
             REQUEST['RESPONSE'].redirect( '%s/manage_propertiesForm'
                                         % self.absolute_url() )
 
-    security.declareProtected(AccessContentsInformation, 'getCustomizableObject')
+    security.declareProtected(ACI, 'getCustomizableObject')
     def getCustomizableObject(self):
         ob = aq_parent(aq_inner(self))
-        while getattr(ob, '_isDirectoryView', 0):
-            ob = aq_parent(aq_inner(ob))
+        while ob:
+            if IDirectoryView.providedBy(ob):
+                ob = aq_parent(ob)
+            elif getattr(ob, '_isDirectoryView', 0):
+                # BBB
+                warn("The '_isDirectoryView' marker attribute is deprecated, "
+                     "and will be removed in CMF 2.3.  Please mark the "
+                     "instance with the 'IDirectoryView' interface instead.",
+                     DeprecationWarning, stacklevel=2)
+                ob = aq_parent(ob)
+            else:
+                break
         return ob
 
-    security.declareProtected(AccessContentsInformation, 'listCustFolderPaths')
+    security.declareProtected(ACI, 'listCustFolderPaths')
     def listCustFolderPaths(self, adding_meta_type=None):
         """ List possible customization folders as key, value pairs.
         """
@@ -569,7 +578,7 @@
         rval.sort()
         return rval
 
-    security.declareProtected(AccessContentsInformation, 'getDirPath')
+    security.declareProtected(ACI, 'getDirPath')
     def getDirPath(self):
         return self.__dict__['_real']._dirpath
 

Modified: CMF/branches/2.1/CMFCore/DiscussionTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/DiscussionTool.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFCore/DiscussionTool.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -48,8 +48,6 @@
     implements(IOldstyleDiscussable)
     __implements__ = z2IOldstyleDiscussable
 
-    _isDiscussable = 1
-
     security = ClassSecurityInfo()
     
 

Modified: CMF/branches/2.1/CMFCore/PortalContent.py
===================================================================
--- CMF/branches/2.1/CMFCore/PortalContent.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFCore/PortalContent.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -46,9 +46,6 @@
     implements(IContentish)
     __implements__ = (z2IContentish, z2IWriteLock, DynamicType.__implements__)
 
-    isPortalContent = 1
-    _isPortalContent = 1  # More reliable than 'isPortalContent'.
-
     manage_options = ( ( { 'label'  : 'Dublin Core'
                          , 'action' : 'manage_metadata'
                          }

Modified: CMF/branches/2.1/CMFCore/PortalFolder.py
===================================================================
--- CMF/branches/2.1/CMFCore/PortalFolder.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFCore/PortalFolder.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -18,6 +18,7 @@
 import base64
 import marshal
 import re
+from warnings import warn
 
 from AccessControl import ClassSecurityInfo
 from AccessControl import getSecurityManager
@@ -39,6 +40,7 @@
 from interfaces import IContentTypeRegistry
 from interfaces import IFolderish
 from interfaces import IMutableMinimalDublinCore
+from interfaces import ISiteRoot
 from interfaces import ITypesTool
 from interfaces.Folderish import Folderish as z2IFolderish
 from permissions import AddPortalContent
@@ -350,9 +352,20 @@
         # This code prevents people other than the portal manager from
         # overriding skinned names and tools.
         if not getSecurityManager().checkPermission(ManagePortal, self):
-            ob = self
-            while ob is not None and not getattr(ob, '_isPortalRoot', False):
-                ob = aq_parent( aq_inner(ob) )
+            ob = aq_inner(self)
+            while ob is not None:
+                if ISiteRoot.providedBy(ob):
+                    break
+                # BBB
+                if getattr(ob, '_isPortalRoot', False):
+                    warn("The '_isPortalRoot' marker attribute for site "
+                         "roots is deprecated and will be removed in "
+                         "CMF 2.3;  please mark the root object with "
+                         "'ISiteRoot' instead.",
+                         DeprecationWarning, stacklevel=2)
+                    break
+                ob = aq_parent(ob)
+
             if ob is not None:
                 # If the portal root has a non-contentish object by this name,
                 # don't allow an override.

Modified: CMF/branches/2.1/CMFCore/PortalObject.py
===================================================================
--- CMF/branches/2.1/CMFCore/PortalObject.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFCore/PortalObject.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -41,7 +41,6 @@
 
     implements(ISiteRoot, IObjectManagerSite)
     meta_type = 'Portal Site'
-    _isPortalRoot = 1
 
     # Ensure certain attributes come from the correct base class.
     __getattr__ = SkinnableObjectManager.__getattr__

Modified: CMF/branches/2.1/CMFCore/TypesTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/TypesTool.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFCore/TypesTool.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -65,8 +65,6 @@
     """ Base class for information about a content type.
     """
 
-    _isTypeInformation = 1
-
     manage_options = ( SimpleItemWithProperties.manage_options[:1]
                      + ( {'label':'Aliases',
                           'action':'manage_aliases'}, )
@@ -634,7 +632,14 @@
             else:
                 return None
         ob = getattr( self, contentType, None )
+        if ITypeInformation.providedBy(ob):
+            return ob
         if getattr(aq_base(ob), '_isTypeInformation', 0):
+            # BBB
+            warn("The '_isTypeInformation' marker attribute is deprecated, "
+                 "and will be removed in CMF 2.3.  Please mark the instance "
+                 "with the 'ITypeInformation' interface instead.",
+                 DeprecationWarning, stacklevel=2)
             return ob
         else:
             return None
@@ -650,17 +655,20 @@
         for t in self.objectValues():
             # Filter out things that aren't TypeInformation and
             # types for which the user does not have adequate permission.
-            if not getattr(aq_base(t), '_isTypeInformation', 0):
-                continue
-            if not t.getId():
-                # XXX What's this used for ?
-                # Not ready.
-                continue
-            # check we're allowed to access the type object
-            if container is not None:
-                if not t.isConstructionAllowed(container):
-                    continue
-            rval.append(t)
+            if ITypeInformation.providedBy(t):
+                rval.append(t)
+            elif getattr(aq_base(t), '_isTypeInformation', 0):
+                # BBB
+                warn("The '_isTypeInformation' marker attribute is deprecated, "
+                     "and will be removed in CMF 2.3.  Please mark the "
+                     "instance with the 'ITypeInformation' interface instead.",
+                     DeprecationWarning, stacklevel=2)
+                rval.append(t)
+        # Skip items with no ID:  old signal for "not ready"
+        rval = [t for t in rval if t.getId()]
+        # check we're allowed to access the type object
+        if container is not None:
+            rval = [t for t in rval if t.isConstructionAllowed(container)]
         return rval
 
     security.declareProtected(AccessContentsInformation, 'listContentTypes')

Modified: CMF/branches/2.1/CMFCore/WorkflowTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/WorkflowTool.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFCore/WorkflowTool.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -16,6 +16,7 @@
 """
 
 import sys
+from warnings import warn
 
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_base, aq_inner, aq_parent
@@ -460,9 +461,16 @@
         """ Retrieve a given workflow.
         """
         wf = getattr(self, wf_id, None)
-        if getattr(wf, '_isAWorkflow', False) or \
-                IWorkflowDefinition.providedBy(wf):
+        if IWorkflowDefinition.providedBy(wf):
             return wf
+        if getattr(wf, '_isAWorkflow', False):
+            # BBB
+            warn("The '_isAWorkflow' marker attribute for workflow "
+                 "definitions is deprecated and will be removed in "
+                 "CMF 2.3;  please mark the definition with "
+                 "'IWorkflowDefinition' instead.",
+                 DeprecationWarning, stacklevel=2)
+            return wf
         else:
             return None
 
@@ -485,8 +493,16 @@
         wf_ids = []
 
         for obj_name, obj in self.objectItems():
-            if getattr(obj, '_isAWorkflow', 0):
+            if IWorkflowDefinition.providedBy(obj):
                 wf_ids.append(obj_name)
+            elif getattr(obj, '_isAWorkflow', 0):
+                # BBB
+                warn("The '_isAWorkflow' marker attribute for workflow "
+                     "definitions is deprecated and will be removed in "
+                     "CMF 2.3;  please mark the definition with "
+                     "'IWorkflowDefinition' instead.",
+                     DeprecationWarning, stacklevel=2)
+                wf_ids.append(obj_name)
 
         return tuple(wf_ids)
 

Modified: CMF/branches/2.1/CMFCore/tests/base/dummy.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/base/dummy.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFCore/tests/base/dummy.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -30,6 +30,7 @@
 
 from Products.CMFCore.interfaces import IContentish
 from Products.CMFCore.interfaces import ISiteRoot
+from Products.CMFCore.interfaces import ITypeInformation
 from Products.CMFCore.ActionProviderBase import ActionProviderBase
 from Products.CMFCore.PortalContent import PortalContent
 
@@ -64,7 +65,7 @@
 
 class DummyType(DummyObject):
     """ A Dummy Type object """
-    _isTypeInformation = True
+    implements(ITypeInformation)
 
     def __init__(self, id='Dummy Content', title='Dummy Content', actions=()):
         """ To fake out some actions, pass in a sequence of tuples where the
@@ -269,7 +270,6 @@
 
     _domain = 'http://www.foobar.com'
     _path = 'bar'
-    _isPortalRoot = 1
     implements(ISiteRoot)
 
     def absolute_url(self, relative=0):

Modified: CMF/branches/2.1/CMFCore/tests/test_WorkflowTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_WorkflowTool.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFCore/tests/test_WorkflowTool.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -23,11 +23,13 @@
 from zope.component import adapter
 from zope.component import getSiteManager
 from zope.component import provideHandler
+from zope.interface import implements
 from Products.CMFCore.interfaces import IActionWillBeInvokedEvent
 from Products.CMFCore.interfaces import IActionRaisedExceptionEvent
 from Products.CMFCore.interfaces import IActionSucceededEvent
-
+from Products.CMFCore.interfaces import IContentish
 from Products.CMFCore.interfaces import ITypesTool
+from Products.CMFCore.interfaces import IWorkflowDefinition
 
 
 class Dummy( SimpleItem ):
@@ -41,6 +43,7 @@
 
 class DummyWorkflow( Dummy ):
 
+    implements(IWorkflowDefinition)
     meta_type = 'DummyWorkflow'
     _isAWorkflow = 1
     _known_actions=()
@@ -123,8 +126,8 @@
 
 class DummyContent( Dummy ):
 
+    implements(IContentish)
     meta_type = 'Dummy'
-    _isPortalContent = 1
 
     def getPortalTypeName(self):
         return 'Dummy Content'

Modified: CMF/branches/2.1/CMFDefault/DefaultWorkflow.py
===================================================================
--- CMF/branches/2.1/CMFDefault/DefaultWorkflow.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFDefault/DefaultWorkflow.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -53,7 +53,6 @@
     meta_type = 'CMF Default Workflow'
     id = 'default_workflow'
     title = 'Simple Review / Publish Policy'
-    _isAWorkflow = 1
 
     security = ClassSecurityInfo()
 

Modified: CMF/branches/2.1/CMFDefault/Document.py
===================================================================
--- CMF/branches/2.1/CMFDefault/Document.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFDefault/Document.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -69,7 +69,6 @@
     effective_date = expiration_date = None
     cooked_text = text = text_format = ''
     _size = 0
-    _isDiscussable = 1
 
     _stx_level = 1                      # Structured text level
 

Modified: CMF/branches/2.1/CMFDefault/File.py
===================================================================
--- CMF/branches/2.1/CMFDefault/File.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFDefault/File.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -88,7 +88,6 @@
                      )
 
     effective_date = expiration_date = None
-    _isDiscussable = 1
     icon = PortalContent.icon
 
     manage_options = ( PortalContent.manage_options

Modified: CMF/branches/2.1/CMFDefault/Image.py
===================================================================
--- CMF/branches/2.1/CMFDefault/Image.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFDefault/Image.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -86,7 +86,6 @@
                      )
     
     effective_date = expiration_date = None
-    _isDiscussable = 1
     icon = PortalContent.icon
 
     manage_options = ( PortalContent.manage_options

Modified: CMF/branches/2.1/CMFDefault/Link.py
===================================================================
--- CMF/branches/2.1/CMFDefault/Link.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/CMFDefault/Link.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -64,7 +64,6 @@
 
     URL_FORMAT = format = 'text/url'
     effective_date = expiration_date = None
-    _isDiscussable = 1
 
     security = ClassSecurityInfo()
 

Modified: CMF/branches/2.1/DCWorkflow/DCWorkflow.py
===================================================================
--- CMF/branches/2.1/DCWorkflow/DCWorkflow.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/DCWorkflow/DCWorkflow.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -71,7 +71,6 @@
     __implements__ = z2IWorkflowDefinition
 
     title = 'DC Workflow Definition'
-    _isAWorkflow = 1
 
     state_var = 'state'
     initial_state = None

Modified: CMF/branches/2.1/DCWorkflow/Expression.py
===================================================================
--- CMF/branches/2.1/DCWorkflow/Expression.py	2007-04-09 21:23:10 UTC (rev 74062)
+++ CMF/branches/2.1/DCWorkflow/Expression.py	2007-04-09 21:23:43 UTC (rev 74063)
@@ -14,6 +14,7 @@
 
 $Id$
 """
+from warnings import warn
 
 import Globals
 from Globals import Persistent
@@ -23,6 +24,7 @@
 
 from Products.CMFCore.WorkflowCore import ObjectDeleted, ObjectMoved
 from Products.CMFCore.Expression import Expression
+from Products.CMFCore.interfaces import ISiteRoot
 from Products.PageTemplates.Expressions import getEngine
 from Products.PageTemplates.Expressions import SecureModuleImporter
 
@@ -95,10 +97,20 @@
             return ()
 
     def getPortal(self):
-        ob = self.object
-        while ob is not None and not getattr(ob, '_isPortalRoot', 0):
-            ob = aq_parent(aq_inner(ob))
-        return ob
+        ob = aq_inner(self.object)
+        while ob is not None:
+            if ISiteRoot.providedBy(ob):
+                return ob
+            if getattr(ob, '_isPortalRoot', None) is not None:
+                # BBB
+                warn("The '_isPortalRoot' marker attribute for site "
+                     "roots is deprecated and will be removed in "
+                     "CMF 2.3;  please mark the root object with "
+                     "'ISiteRoot' instead.",
+                     DeprecationWarning, stacklevel=2)
+                return ob
+            ob = aq_parent(ob)
+        return None
 
     def getDateTime(self):
         date = self._date



More information about the CMF-checkins mailing list