[CMF-checkins] CVS: Products/CMFCore - PortalContent.py:1.47.8.1 TypesTool.py:1.77.2.1 utils.py:1.61.2.1

Yvo Schubbe y.2004_ at wcm-solutions.de
Fri Sep 10 11:42:27 EDT 2004


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

Modified Files:
      Tag: yuppie-post_1_5-cleanup-branch
	PortalContent.py TypesTool.py utils.py 
Log Message:
- removed deprecated _getViewFor / getActionById machinery


=== Products/CMFCore/PortalContent.py 1.47 => 1.47.8.1 ===
--- Products/CMFCore/PortalContent.py:1.47	Thu Aug 12 11:07:39 2004
+++ Products/CMFCore/PortalContent.py	Fri Sep 10 11:41:56 2004
@@ -23,8 +23,8 @@
 
 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
@@ -95,22 +95,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/TypesTool.py 1.77 => 1.77.2.1 ===
--- Products/CMFCore/TypesTool.py:1.77	Tue Sep  7 04:48:37 2004
+++ Products/CMFCore/TypesTool.py	Fri Sep 10 11:41:56 2004
@@ -270,38 +270,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.


=== Products/CMFCore/utils.py 1.61 => 1.61.2.1 ===
--- Products/CMFCore/utils.py:1.61	Mon Sep  6 03:05:10 2004
+++ Products/CMFCore/utils.py	Fri Sep 10 11:41:56 2004
@@ -146,23 +146,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'   : ''
@@ -175,46 +163,6 @@
            , 'member'       : None
            }
     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.



More information about the CMF-checkins mailing list