[CMF-checkins] CVS: Products/CMFCore - ActionsTool.py:1.54 CatalogTool.py:1.56 PortalContent.py:1.48 PortalFolder.py:1.74 TypesTool.py:1.78 __init__.py:1.29 utils.py:1.62 CMFCorePermissions.py:NONE

Yvo Schubbe y.2004_ at wcm-solutions.de
Tue Sep 14 15:02:52 EDT 2004


Update of /cvs-repository/Products/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv2613/CMFCore

Modified Files:
	ActionsTool.py CatalogTool.py PortalContent.py PortalFolder.py 
	TypesTool.py __init__.py utils.py 
Removed Files:
	CMFCorePermissions.py 
Log Message:
Merged yuppie-post_1_5-cleanup-branch:
- removed a lot of deprecated code
- made CMFCollector work with CMF 1.4 *and* HEAD


=== Products/CMFCore/ActionsTool.py 1.53 => 1.54 ===
--- Products/CMFCore/ActionsTool.py:1.53	Mon Aug 30 04:59:52 2004
+++ Products/CMFCore/ActionsTool.py	Tue Sep 14 15:02:21 2004
@@ -175,8 +175,4 @@
             #    catlist.append(action)
         return filtered_actions
 
-    # listFilteredActions() is an alias.
-    security.declarePublic('listFilteredActions')
-    listFilteredActions = listFilteredActionsFor
-
 InitializeClass(ActionsTool)


=== Products/CMFCore/CatalogTool.py 1.55 => 1.56 ===
--- Products/CMFCore/CatalogTool.py:1.55	Thu Aug 12 11:07:39 2004
+++ Products/CMFCore/CatalogTool.py	Tue Sep 14 15:02:21 2004
@@ -108,12 +108,9 @@
     def enumerateIndexes( self ):
         #   Return a list of ( index_name, type ) pairs for the initial
         #   index set.
-        #   Creator is deprecated and may go away, use listCreators!
-        #   meta_type is deprecated and may go away, use portal_type!
         return ( ('Title', 'TextIndex')
                , ('Subject', 'KeywordIndex')
                , ('Description', 'TextIndex')
-               , ('Creator', 'FieldIndex')
                , ('listCreators', 'KeywordIndex')
                , ('SearchableText', 'TextIndex')
                , ('Date', 'FieldIndex')
@@ -125,7 +122,6 @@
                , ('allowedRolesAndUsers', 'KeywordIndex')
                , ('review_state', 'FieldIndex')
                , ('in_reply_to', 'FieldIndex')
-               , ('meta_type', 'FieldIndex')
                , ('getId', 'FieldIndex')
                , ('path', 'PathIndex')
                , ('portal_type', 'FieldIndex')
@@ -134,13 +130,11 @@
     security.declarePublic( 'enumerateColumns' )
     def enumerateColumns( self ):
         #   Return a sequence of schema names to be cached.
-        #   Creator is deprecated and may go away, use listCreators!
         return ( 'Subject'
                , 'Title'
                , 'Description'
                , 'Type'
                , 'review_state'
-               , 'Creator'
                , 'listCreators'
                , 'Date'
                , 'getIcon'


=== Products/CMFCore/PortalContent.py 1.47 => 1.48 ===
--- Products/CMFCore/PortalContent.py:1.47	Thu Aug 12 11:07:39 2004
+++ Products/CMFCore/PortalContent.py	Tue Sep 14 15:02:21 2004
@@ -23,17 +23,13 @@
 
 from interfaces.Contentish import Contentish
 from DynamicType import DynamicType
-from utils import _getViewFor
 from CMFCatalogAware import CMFCatalogAware
+from exceptions import NotFound
 from exceptions import ResourceLockedError
 from permissions import FTPAccess
 from permissions import View
 
 
-# Old names that some third-party packages may need.
-NoWL = 0
-
-
 class PortalContent(DynamicType, CMFCatalogAware, SimpleItem):
     """
         Base class for portal objects.
@@ -95,22 +91,18 @@
         return "%s %s" % (self.Title(), self.Description())
 
     def __call__(self):
-        '''
-        Invokes the default view.
-        '''
-        view = _getViewFor(self)
-        if getattr(aq_base(view), 'isDocTemp', 0):
-            return view(self, self.REQUEST)
+        """ Invokes the default view.
+        """
+        ti = self.getTypeInfo()
+        method_id = ti and ti.queryMethodID('(Default)')
+        if method_id:
+            method = getattr(self, method_id)
+            if getattr(aq_base(method), 'isDocTemp', 0):
+                return method(self, self.REQUEST)
+            else:
+                return method()
         else:
-            return view()
-
-    index_html = None  # This special value informs ZPublisher to use __call__
-
-    security.declareProtected(View, 'view')
-    def view(self):
-        '''
-        Returns the default view even if index_html is overridden.
-        '''
-        return self()
+            raise NotFound( 'Cannot find default view for "%s"' %
+                            '/'.join( obj.getPhysicalPath() ) )
 
 InitializeClass(PortalContent)


=== Products/CMFCore/PortalFolder.py 1.73 => 1.74 ===
--- Products/CMFCore/PortalFolder.py:1.73	Tue Sep  7 04:48:37 2004
+++ Products/CMFCore/PortalFolder.py	Tue Sep 14 15:02:21 2004
@@ -18,7 +18,6 @@
 import base64
 import marshal
 import re
-from warnings import warn
 
 from AccessControl import ClassSecurityInfo
 from AccessControl import getSecurityManager
@@ -169,30 +168,6 @@
             return self.folder_contents( # XXX: ick!
                 self, REQUEST, portal_status_message="Folder added")
 
-    def _morphSpec(self, spec):
-        '''
-        spec is a sequence of meta_types, a string containing one meta type,
-        or None.  If spec is empty or None, returns all contentish
-        meta_types.  Otherwise ensures all of the given meta types are
-        contentish.
-        '''
-        warn('Using the \'spec\' argument is deprecated. In CMF 1.6 '
-             'contentItems(), contentIds(), contentValues() and '
-             'listFolderContents() will no longer support \'spec\'. Use the '
-             '\'filter\' argument with \'portal_type\' instead.',
-             DeprecationWarning)
-        new_spec = []
-        types_tool = getToolByName(self, 'portal_types')
-        types = types_tool.listContentTypes( by_metatype=1 )
-        if spec is not None:
-            if type(spec) == type(''):
-                spec = [spec]
-            for meta_type in spec:
-                if not meta_type in types:
-                    raise ValueError('%s is not a content type' % meta_type)
-                new_spec.append(meta_type)
-        return new_spec or types
-
     def _filteredItems( self, ids, filt ):
         """
             Apply filter, a mapping, to child objects indicated by 'ids',
@@ -230,44 +205,29 @@
         return result
 
     security.declarePublic('contentIds')
-    def contentIds( self, spec=None, filter=None):
+    def contentIds(self, filter=None):
         """
             Provide a filtered view onto 'objectIds', allowing only
             PortalFolders and PortalContent-derivatives to show through.
         """
-        if spec is None:
-            ids = self.objectIds()
-        else:
-            # spec is deprecated, use filter instead!
-            spec = self._morphSpec(spec)
-            ids = self.objectIds(spec)
-        return map( lambda item: item[0],
-                    self._filteredItems( ids, filter ) )
+        return [ item[0] for item in self.contentItems(filter) ]
 
     security.declarePublic('contentValues')
-    def contentValues( self, spec=None, filter=None ):
+    def contentValues(self, filter=None):
         """
             Provide a filtered view onto 'objectValues', allowing only
             PortalFolders and PortalContent-derivatives to show through.
         """
-        if spec is None:
-            ids = self.objectIds()
-        else:
-            # spec is deprecated, use filter instead!
-            spec = self._morphSpec(spec)
-            ids = self.objectIds(spec)
-        return map( lambda item: item[1],
-                    self._filteredItems( ids, filter ) )
+        return [ item[1] for item in self.contentItems(filter) ]
 
     security.declareProtected(ListFolderContents, 'listFolderContents')
-    def listFolderContents( self, spec=None, contentFilter=None ):
+    def listFolderContents(self, contentFilter=None):
         """
             Hook around 'contentValues' to let 'folder_contents'
             be protected.  Duplicating skip_unauthorized behavior of dtml-in.
         """
-        items = self.contentItems(spec=spec, filter=contentFilter)
         l = []
-        for id, obj in items:
+        for id, obj in self.contentItems(contentFilter):
             # validate() can either raise Unauthorized or return 0 to
             # mean unauthorized.
             try:
@@ -278,18 +238,13 @@
         return l
 
     security.declarePublic('contentItems')
-    def contentItems( self, spec=None, filter=None ):
+    def contentItems(self, filter=None):
         """
             Provide a filtered view onto 'objectItems', allowing only
             PortalFolders and PortalContent-derivatives to show through.
         """
-        if spec is None:
-            ids = self.objectIds()
-        else:
-            # spec is deprecated, use filter instead!
-            spec = self._morphSpec(spec)
-            ids = self.objectIds(spec)
-        return self._filteredItems( ids, filter )
+        ids = self.objectIds()
+        return self._filteredItems(ids, filter)
 
     # protected by 'WebDAV access'
     def listDAVObjects(self):
@@ -563,7 +518,6 @@
         Represent a predicate against a content object's metadata.
     """
     MARKER = []
-    filterCreator = []
     filterSubject = []
     def __init__( self
                 , Title=MARKER
@@ -588,8 +542,7 @@
             self.description.append( 'Title: %s' % Title )
 
         if Creator and Creator is not self.MARKER:
-            self.filterCreator = Creator
-            self.predicates.append( lambda x, creator=self.filterCreator:
+            self.predicates.append( lambda x, creator=Creator:
                                     creator in x.listCreators() )
             self.description.append( 'Creator: %s' % Creator )
 


=== Products/CMFCore/TypesTool.py 1.77 => 1.78 ===
--- Products/CMFCore/TypesTool.py:1.77	Tue Sep  7 04:48:37 2004
+++ Products/CMFCore/TypesTool.py	Tue Sep 14 15:02:21 2004
@@ -177,13 +177,6 @@
     #
     #   Accessors
     #
-    security.declareProtected(View, 'Type')
-    def Type(self):
-        """ Deprecated. Use Title(). """
-        warn('TypeInformation.Type() is deprecated, use Title().',
-             DeprecationWarning)
-        return self.Title()
-
     security.declareProtected(View, 'Title')
     def Title(self):
         """
@@ -270,38 +263,6 @@
 
         return self._actions or ()
 
-    security.declarePublic('getActionById')
-    def getActionById( self, id, default=_marker ):
-        """ Get method ID by action ID.
-        """
-        warn('getActionById() is deprecated and will be removed in CMF 1.6. '
-             'Please use getActionInfo()[\'url\'] if you need an URL or '
-             'queryMethodID() if you need a method ID.',
-             DeprecationWarning)
-        context = getActionContext( self )
-        for action in self.listActions():
-
-            __traceback_info__ = (self.getId(), action)
-
-            if action.getId() == id:
-                target = action.action(context).strip()
-                if target.startswith('/'):
-                    target = target[1:]
-                return target
-            else:
-                # Temporary backward compatibility.
-                if action.Title().lower() == id:
-                    target = action.action(context).strip()
-                    if target.startswith('/'):
-                        target = target[1:]
-                    return target
-
-        if default is _marker:
-            raise ValueError, ('No action "%s" for type "%s"'
-                               % (id, self.getId()))
-        else:
-            return default
-
     security.declarePrivate( '_convertActions' )
     def _convertActions( self ):
         """ Upgrade dictionary-based actions.
@@ -879,7 +840,6 @@
         result = typenames.keys()
         result.sort()
         return result
-
 
     security.declarePublic('constructContent')
     def constructContent( self


=== Products/CMFCore/__init__.py 1.28 => 1.29 ===
--- Products/CMFCore/__init__.py:1.28	Thu Aug 12 11:07:39 2004
+++ Products/CMFCore/__init__.py	Tue Sep 14 15:02:21 2004
@@ -34,10 +34,6 @@
 from permissions import AddPortalFolders
 
 
-# Old name that some third-party packages may need.
-ADD_FOLDERS_PERMISSION = AddPortalFolders
-HAS_PAGE_TEMPLATES = 1
-
 bases = (
     PortalObject.PortalObjectBase,
     PortalFolder.PortalFolder,


=== Products/CMFCore/utils.py 1.61 => 1.62 ===
--- Products/CMFCore/utils.py:1.61	Mon Sep  6 03:05:10 2004
+++ Products/CMFCore/utils.py	Tue Sep 14 15:02:21 2004
@@ -18,7 +18,6 @@
 from os import path as os_path
 from os.path import abspath
 import re
-from warnings import warn
 
 from AccessControl import ClassSecurityInfo
 from AccessControl import getSecurityManager
@@ -44,7 +43,6 @@
 from OFS.SimpleItem import SimpleItem
 from Products.PageTemplates.Expressions import getEngine
 from Products.PageTemplates.Expressions import SecureModuleImporter
-from StructuredText.StructuredText import HTML
 
 from exceptions import AccessControl_Unauthorized
 from exceptions import NotFound
@@ -146,23 +144,11 @@
 
     return context.user.allowed(obj, roles)
 
-security.declarePrivate('_verifyActionPermissions')
-def _verifyActionPermissions(obj, action):
-    # _verifyActionPermissions is deprecated and will be removed in CMF 1.6.
-    # This was only used by the deprecated _getViewFor function.
-    pp = action.getPermissions()
-    if not pp:
-        return 1
-    for p in pp:
-        if _checkPermission(p, obj):
-            return 1
-    return 0
-
 security.declarePublic( 'getActionContext' )
 def getActionContext( self ):
-    # getActionContext is deprecated and will be removed in CMF 1.6.
-    # This is only used by the deprecated _getViewFor function and the
-    # deprecated getActionById method.
+    # getActionContext is deprecated and will be removed as soon as the
+    # backwards compatibility code in TypeInformation._guessMethodAliases is
+    # removed.
     data = { 'object_url'   : ''
            , 'folder_url'   : ''
            , 'portal_url'   : ''
@@ -176,46 +162,6 @@
            }
     return getEngine().getContext( data )
 
-security.declarePrivate('_getViewFor')
-def _getViewFor(obj, view='view'):
-    warn('__call__() and view() methods using _getViewFor() as well as '
-         '_getViewFor() itself are deprecated and will be removed in CMF 1.6. '
-         'Bypass these methods by defining \'(Default)\' and \'view\' Method '
-         'Aliases.',
-         DeprecationWarning)
-    ti = obj.getTypeInfo()
-
-    if ti is not None:
-
-        context = getActionContext( obj )
-        actions = ti.listActions()
-
-        for action in actions:
-            if action.getId() == view:
-                if _verifyActionPermissions( obj, action ):
-                    target = action.action(context).strip()
-                    if target.startswith('/'):
-                        target = target[1:]
-                    __traceback_info__ = ( ti.getId(), target )
-                    return obj.restrictedTraverse( target )
-
-        # "view" action is not present or not allowed.
-        # Find something that's allowed.
-        for action in actions:
-            if _verifyActionPermissions(obj, action):
-                target = action.action(context).strip()
-                if target.startswith('/'):
-                    target = target[1:]
-                __traceback_info__ = ( ti.getId(), target )
-                return obj.restrictedTraverse( target )
-
-        raise AccessControl_Unauthorized( 'No accessible views available for '
-                                    '%s' % '/'.join( obj.getPhysicalPath() ) )
-    else:
-        raise NotFound('Cannot find default view for "%s"' %
-                            '/'.join(obj.getPhysicalPath()))
-
-
 # If Zope ever provides a call to getRolesInContext() through
 # the SecurityManager API, the method below needs to be updated.
 security.declarePrivate('_limitGrantedRoles')
@@ -234,8 +180,6 @@
         if role not in special_roles and role not in user_roles:
             raise AccessControl_Unauthorized('Too many roles specified.')
 
-limitGrantedRoles = _limitGrantedRoles  # XXX: Deprecated spelling
-
 security.declarePrivate('_mergedLocalRoles')
 def _mergedLocalRoles(object):
     """Returns a merging of object and its ancestors'
@@ -263,8 +207,6 @@
         break
     return merged
 
-mergedLocalRoles = _mergedLocalRoles    # XXX: Deprecated spelling
-
 security.declarePrivate('_ac_inherited_permissions')
 def _ac_inherited_permissions(ob, all=0):
     # Get all permissions not defined in ourself that are inherited
@@ -597,15 +539,6 @@
     if not hasattr(misc_images, pid):
         setattr(misc_images, pid, MiscImage(pid, {}))
     getattr(misc_images, pid)[name]=icon
-
-security.declarePublic('format_stx')
-def format_stx( text, level=1 ):
-    """ Render STX to HTML.
-    """
-    warn('format_stx() will be removed in CMF 1.6. Please use '
-         'StructuredText.StructuredText.HTML instead.',
-         DeprecationWarning)
-    return HTML(text, level=level, header=0)
 
 #
 #   Metadata Keyword splitter utilities

=== Removed File Products/CMFCore/CMFCorePermissions.py ===



More information about the CMF-checkins mailing list