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

Tres Seaver tseaver at palladion.com
Mon Apr 9 17:27:56 EDT 2007


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

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

-=-
Modified: CMF/trunk/CMFCore/ActionInformation.py
===================================================================
--- CMF/trunk/CMFCore/ActionInformation.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFCore/ActionInformation.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -248,7 +248,6 @@
 
     implements(IAction)
 
-    _isActionInformation = 1
     __allow_access_to_unprotected_subobjects__ = 1
 
     security = ClassSecurityInfo()

Modified: CMF/trunk/CMFCore/DirectoryView.py
===================================================================
--- CMF/trunk/CMFCore/DirectoryView.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFCore/DirectoryView.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -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/trunk/CMFCore/DiscussionTool.py
===================================================================
--- CMF/trunk/CMFCore/DiscussionTool.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFCore/DiscussionTool.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -48,8 +48,6 @@
 
     implements(IOldstyleDiscussable)
 
-    _isDiscussable = 1
-
     security = ClassSecurityInfo()
 
     def __init__( self, content ):

Modified: CMF/trunk/CMFCore/PortalContent.py
===================================================================
--- CMF/trunk/CMFCore/PortalContent.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFCore/PortalContent.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -43,9 +43,6 @@
 
     implements(IContentish)
 
-    isPortalContent = 1
-    _isPortalContent = 1  # More reliable than 'isPortalContent'.
-
     manage_options = ( ( { 'label'  : 'Dublin Core'
                          , 'action' : 'manage_metadata'
                          }

Modified: CMF/trunk/CMFCore/PortalFolder.py
===================================================================
--- CMF/trunk/CMFCore/PortalFolder.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFCore/PortalFolder.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -18,6 +18,7 @@
 import base64
 import marshal
 import re
+from warnings import warn
 
 from AccessControl import ClassSecurityInfo
 from AccessControl import getSecurityManager
@@ -38,6 +39,7 @@
 from interfaces import IContentTypeRegistry
 from interfaces import IFolderish
 from interfaces import IMutableMinimalDublinCore
+from interfaces import ISiteRoot
 from interfaces import ITypesTool
 from permissions import AddPortalContent
 from permissions import AddPortalFolders
@@ -346,9 +348,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/trunk/CMFCore/PortalObject.py
===================================================================
--- CMF/trunk/CMFCore/PortalObject.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFCore/PortalObject.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -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/trunk/CMFCore/TypesTool.py
===================================================================
--- CMF/trunk/CMFCore/TypesTool.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFCore/TypesTool.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -60,8 +60,6 @@
     """ Base class for information about a content type.
     """
 
-    _isTypeInformation = 1
-
     manage_options = ( SimpleItemWithProperties.manage_options[:1]
                      + ( {'label':'Aliases',
                           'action':'manage_aliases'}, )
@@ -626,7 +624,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
@@ -642,17 +647,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/trunk/CMFCore/WorkflowTool.py
===================================================================
--- CMF/trunk/CMFCore/WorkflowTool.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFCore/WorkflowTool.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -16,6 +16,7 @@
 """
 
 import sys
+from warnings import warn
 
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_base, aq_inner, aq_parent
@@ -457,9 +458,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
 
@@ -482,8 +490,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/trunk/CMFCore/tests/base/dummy.py
===================================================================
--- CMF/trunk/CMFCore/tests/base/dummy.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFCore/tests/base/dummy.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -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/trunk/CMFCore/tests/test_WorkflowTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_WorkflowTool.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFCore/tests/test_WorkflowTool.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -22,13 +22,16 @@
 from zope.component import adapter
 from zope.component import getSiteManager
 from zope.component import provideHandler
+from zope.interface import implements
 from zope.interface.verify import verifyClass
 from zope.testing.cleanup import cleanUp
 
 from Products.CMFCore.interfaces import IActionRaisedExceptionEvent
 from Products.CMFCore.interfaces import IActionSucceededEvent
 from Products.CMFCore.interfaces import IActionWillBeInvokedEvent
+from Products.CMFCore.interfaces import IContentish
 from Products.CMFCore.interfaces import ITypesTool
+from Products.CMFCore.interfaces import IWorkflowDefinition
 
 
 class Dummy( SimpleItem ):
@@ -42,6 +45,7 @@
 
 class DummyWorkflow( Dummy ):
 
+    implements(IWorkflowDefinition)
     meta_type = 'DummyWorkflow'
     _isAWorkflow = 1
     _known_actions=()
@@ -124,8 +128,8 @@
 
 class DummyContent( Dummy ):
 
+    implements(IContentish)
     meta_type = 'Dummy'
-    _isPortalContent = 1
 
     def getPortalTypeName(self):
         return 'Dummy Content'

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

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

Modified: CMF/trunk/CMFDefault/File.py
===================================================================
--- CMF/trunk/CMFDefault/File.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFDefault/File.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -85,7 +85,6 @@
     implements(IMutableFile, IFile, IDAVAware)
 
     effective_date = expiration_date = None
-    _isDiscussable = 1
     icon = PortalContent.icon
 
     manage_options = ( PortalContent.manage_options

Modified: CMF/trunk/CMFDefault/Image.py
===================================================================
--- CMF/trunk/CMFDefault/Image.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFDefault/Image.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -83,7 +83,6 @@
     implements(IMutableImage, IImage, IDAVAware)
 
     effective_date = expiration_date = None
-    _isDiscussable = 1
     icon = PortalContent.icon
 
     manage_options = ( PortalContent.manage_options

Modified: CMF/trunk/CMFDefault/Link.py
===================================================================
--- CMF/trunk/CMFDefault/Link.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/CMFDefault/Link.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -61,7 +61,6 @@
 
     URL_FORMAT = format = 'text/url'
     effective_date = expiration_date = None
-    _isDiscussable = 1
 
     security = ClassSecurityInfo()
 

Modified: CMF/trunk/DCWorkflow/DCWorkflow.py
===================================================================
--- CMF/trunk/DCWorkflow/DCWorkflow.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/DCWorkflow/DCWorkflow.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -67,7 +67,6 @@
     implements(IDCWorkflowDefinition, IWorkflowDefinition)
 
     title = 'DC Workflow Definition'
-    _isAWorkflow = 1
 
     state_var = 'state'
     initial_state = None

Modified: CMF/trunk/DCWorkflow/Expression.py
===================================================================
--- CMF/trunk/DCWorkflow/Expression.py	2007-04-09 21:23:43 UTC (rev 74063)
+++ CMF/trunk/DCWorkflow/Expression.py	2007-04-09 21:27:55 UTC (rev 74064)
@@ -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