[CMF-checkins] CVS: CMF/CMFCore - ActionInformation.py:1.15 TypesTool.py:1.53 utils.py:1.39

Sidnei da Silva sidnei@x3ng.com.br
Wed, 23 Apr 2003 12:51:59 -0400


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

Modified Files:
	ActionInformation.py TypesTool.py utils.py 
Log Message:
Some changes to ActionInformation to make it a bit more backward compatible.

=== CMF/CMFCore/ActionInformation.py 1.14 => 1.15 ===
--- CMF/CMFCore/ActionInformation.py:1.14	Thu Feb 13 03:28:42 2003
+++ CMF/CMFCore/ActionInformation.py	Wed Apr 23 12:51:57 2003
@@ -24,6 +24,7 @@
 from CMFCorePermissions import View
 from CMFCorePermissions import ManagePortal
 from utils import getToolByName
+from types import StringType
 
 class ActionInformation( SimpleItem ):
 
@@ -64,7 +65,7 @@
         self.permissions = permissions
         self.priority = priority 
         self.visible = visible
-        self.action = action
+        self.setActionExpression(action)
 
     security.declareProtected( View, 'Title' )
     def Title(self):
@@ -99,6 +100,8 @@
         info = {}
         info['id'] = self.id
         info['name'] = self.Title()
+        expr = self.getActionExpression()
+        __traceback_info__ = (info['id'], info['name'], expr)
         action_obj = self._getActionObject()
         info['url'] = action_obj and action_obj( ec ) or ''
         info['permissions'] = self.getPermissions()
@@ -127,7 +130,20 @@
         """ Return the text of the TALES expression for our URL.
         """
         action = self._getActionObject()
-        return action and action.text or ''
+        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
+                self.action = Expression( expr )
+        return expr
+
+    security.declarePrivate( 'setActionExpression' )
+    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 = Expression( action )
+        self.action = action
 
     security.declarePublic( 'getCondition' )
     def getCondition(self):


=== CMF/CMFCore/TypesTool.py 1.52 => 1.53 ===
--- CMF/CMFCore/TypesTool.py:1.52	Tue Apr 15 12:08:01 2003
+++ CMF/CMFCore/TypesTool.py	Wed Apr 23 12:51:57 2003
@@ -254,6 +254,8 @@
         context = getActionContext( self )
         for action in self.listActions() or ():
 
+            __traceback_info__ = (self.getId(), action)
+
             if action.getId() == id:
                 return action.action( context )
             else:


=== CMF/CMFCore/utils.py 1.38 => 1.39 ===
--- CMF/CMFCore/utils.py:1.38	Tue Apr 15 12:08:01 2003
+++ CMF/CMFCore/utils.py	Wed Apr 23 12:51:57 2003
@@ -157,13 +157,17 @@
 
             if action.getId() == view:
                 if _verifyActionPermissions( obj, action ):
-                    return obj.restrictedTraverse( action.action( context ) )
+                    target = action.action( context )
+                    __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):
-                return obj.restrictedTraverse( action.action( context ) )
+                target = action.action( context )
+                __traceback_info__ = ( ti.getId(), target )
+                return obj.restrictedTraverse( target )
 
         raise 'Unauthorized', ('No accessible views available for %s' %
                                '/'.join(obj.getPhysicalPath()))