[CMF-checkins] CVS: CMF/CMFCore - ActionInformation.py:1.15.2.1 PortalFolder.py:1.45.4.1 TypesTool.py:1.53.2.1 utils.py:1.39.2.1

Yvo Schubbe schubbe@web.de
Fri, 9 May 2003 17:32:08 -0400


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv20972/CMFCore

Modified Files:
      Tag: CMF-1_4-branch
	ActionInformation.py PortalFolder.py TypesTool.py utils.py 
Log Message:
Merged yuppie-collector152-branch:
- Made type actions absolute URLs by default. (Collector #152)

=== CMF/CMFCore/ActionInformation.py 1.15 => 1.15.2.1 ===
--- CMF/CMFCore/ActionInformation.py:1.15	Wed Apr 23 12:51:57 2003
+++ CMF/CMFCore/ActionInformation.py	Fri May  9 17:31:37 2003
@@ -133,7 +133,7 @@
         expr = action and action.text or ''
         if expr and type( expr ) is StringType:
             if not expr.startswith('python:') and not expr.startswith('string:'):
-                expr = 'string:%s' % expr
+                expr = 'string:${object_url}/%s' % expr
                 self.action = Expression( expr )
         return expr
 
@@ -141,7 +141,7 @@
     def setActionExpression(self, action):
         if action and type( action ) is StringType:
             if not action.startswith('python:')  and not action.startswith('string:'):
-                action = 'string:%s' % action
+                action = 'string:${object_url}/%s' % action
                 action = Expression( action )
         self.action = action
 


=== CMF/CMFCore/PortalFolder.py 1.45 => 1.45.4.1 ===
--- CMF/CMFCore/PortalFolder.py:1.45	Tue Apr 15 12:08:01 2003
+++ CMF/CMFCore/PortalFolder.py	Fri May  9 17:31:37 2003
@@ -1,14 +1,14 @@
 ##############################################################################
 #
 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 ##############################################################################
 """ PortalFolder: CMF-enabled Folder objects.
 
@@ -43,19 +43,20 @@
   , 'immediate_view' : 'folder_edit_form'
   , 'actions'        : ( { 'id'            : 'view'
                          , 'name'          : 'View'
-                         , 'action'        : 'string:'
+                         , 'action': 'string:${object_url}'
                          , 'permissions'   : (View,)
                          , 'category'      : 'folder'
                          }
                        , { 'id'            : 'edit'
                          , 'name'          : 'Edit'
-                         , 'action'        : 'string:folder_edit_form'
+                         , 'action': 'string:${object_url}/folder_edit_form'
                          , 'permissions'   : (ManageProperties,)
                          , 'category'      : 'folder'
                          }
                        , { 'id'            : 'localroles'
                          , 'name'          : 'Local Roles'
-                         , 'action'        : 'string:folder_localrole_form'
+                         , 'action':
+                                  'string:${object_url}/folder_localrole_form'
                          , 'permissions'   : (ManageProperties,)
                          , 'category'      : 'folder'
                          }


=== CMF/CMFCore/TypesTool.py 1.53 => 1.53.2.1 ===
--- CMF/CMFCore/TypesTool.py:1.53	Wed Apr 23 12:51:57 2003
+++ CMF/CMFCore/TypesTool.py	Fri May  9 17:31:38 2003
@@ -252,16 +252,22 @@
             Return the URL of the action whose ID is id.
         """
         context = getActionContext( self )
-        for action in self.listActions() or ():
+        for action in self.listActions():
 
             __traceback_info__ = (self.getId(), action)
 
             if action.getId() == id:
-                return action.action( context )
+                target = action.action(context).strip()
+                if target.startswith('/'):
+                    target = target[1:]
+                return target
             else:
                 # Temporary backward compatibility.
                 if action.Title().lower() == id:
-                    return action.action( context )
+                    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"'
@@ -274,39 +280,24 @@
         """
             Upgrade dictionary-based actions.
         """
-        if not self._actions:
-            return
+        aa, self._actions = self._actions, ()
 
-        if type( self._actions[0] ) == type( {} ):
+        for action in aa:
 
-            aa, self._actions = self._actions, ()
-
-            for action in aa:
-
-                # XXX:  historically, action['action'] is simple string
-
-                self.addAction( id=action['id']
-                            , name=action['name']
-                            , action='string:%s' % action.get( 'action' )
-                            , condition=action.get( 'condition' )
-                            , permission=action.get('permissions', () )
-                            , category=action.get( 'category', 'object' )
-                            , visible=action.get( 'visible', 1 )
-                            )
-        else:
-
-            new_actions = []
-            for clone in self._cloneActions():
-
-                a_expr = clone.getActionExpression()
-
-                # XXX heuristic, may miss
-                if a_expr and ':' not in a_expr and '/' not in a_expr:
-                    clone.action = Expression( 'string:%s' % a_expr )
-
-                new_actions.append( clone )
-
-            self._actions = tuple( new_actions )
+            # XXX:  historically, action['action'] is simple string
+            actiontext = action.get('action')
+            if actiontext:
+                actiontext = '/' + actiontext
+
+            self.addAction(
+                  id=action['id']
+                , name=action['name']
+                , action='string:${object_url}%s' % actiontext
+                , condition=action.get('condition')
+                , permission=action.get( 'permissions', () )
+                , category=action.get('category', 'object')
+                , visible=action.get('visible', 1)
+                )
 
     security.declarePrivate('_finishConstruction')
     def _finishConstruction(self, ob):


=== CMF/CMFCore/utils.py 1.39 => 1.39.2.1 ===
--- CMF/CMFCore/utils.py:1.39	Wed Apr 23 12:51:57 2003
+++ CMF/CMFCore/utils.py	Fri May  9 17:31:38 2003
@@ -154,10 +154,11 @@
         actions = ti.listActions()
 
         for action in actions:
-
             if action.getId() == view:
                 if _verifyActionPermissions( obj, action ):
-                    target = action.action( context )
+                    target = action.action(context).strip()
+                    if target.startswith('/'):
+                        target = target[1:]
                     __traceback_info__ = ( ti.getId(), target )
                     return obj.restrictedTraverse( target )
 
@@ -165,7 +166,9 @@
         # Find something that's allowed.
         for action in actions:
             if _verifyActionPermissions(obj, action):
-                target = action.action( context )
+                target = action.action(context).strip()
+                if target.startswith('/'):
+                    target = target[1:]
                 __traceback_info__ = ( ti.getId(), target )
                 return obj.restrictedTraverse( target )