[CMF-checkins] CVS: CMF/CMFCore - TypesTool.py:1.53.4.1 utils.py:1.39.4.1

Yvo Schubbe schubbe@web.de
Thu, 8 May 2003 07:22:14 -0400


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

Modified Files:
      Tag: yuppie-collector152-branch
	TypesTool.py utils.py 
Log Message:
made "string:${object_url}/whatever_view" work (Collector #152)

=== CMF/CMFCore/TypesTool.py 1.53 => 1.53.4.1 ===
--- CMF/CMFCore/TypesTool.py:1.53	Wed Apr 23 12:51:57 2003
+++ CMF/CMFCore/TypesTool.py	Thu May  8 07:21:43 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.4.1 ===
--- CMF/CMFCore/utils.py:1.39	Wed Apr 23 12:51:57 2003
+++ CMF/CMFCore/utils.py	Thu May  8 07:21:43 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 )