[CMF-checkins] CVS: CMF/CMFCore - ActionsTool.py:1.29 TypesTool.py:1.39
Chris McDonough
chrism@zope.com
Thu, 25 Jul 2002 10:52:58 -0400
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv4507
Modified Files:
ActionsTool.py TypesTool.py
Log Message:
Do not molest the actions dictionary during listFilteredActionsFor and the TTW editing methods of the types tool.
=== CMF/CMFCore/ActionsTool.py 1.28 => 1.29 ===
from Expression import Expression, createExprContext
from ActionInformation import ActionInformation, oai
from ActionProviderBase import ActionProviderBase
-
+from TypesTool import TypeInformation
class ActionsTool(UniqueObject, OFS.Folder.Folder, ActionProviderBase):
"""
@@ -200,29 +200,28 @@
if object is not None:
base = aq_base(object)
types_tool = getToolByName( self, 'portal_types' )
- ti = types_tool.getTypeInfo( object )
- if ti is not None:
- defs = ti.getActions()
- if defs:
- c_url = object.absolute_url()
- for d in defs:
- a = d['action']
- if a:
- url = c_url + '/' + a
- else:
- url = c_url
- actions.append({
- 'id': d.get('id', None),
- 'name': d['name'],
- 'action': d['action'],
- 'url': url,
- 'permissions': d['permissions'],
- 'category': d.get('category', 'object'),
- 'visible': d.get('visible', 1),
- })
+ # we might get None back from getTypeInfo. We construct
+ # a dummy TypeInformation object here in that case (the 'or'
+ # case). This prevents us from needing to check the condition.
+ ti = types_tool.getTypeInfo( object ) or TypeInformation('Dummy')
+ defs = ti.getActions()
+ url = object.absolute_url()
+ for d in defs:
+ # we can't modify or expose the original actionsd... this
+ # stems from the fact that getActions returns a ref to the
+ # actual dictionary used to store actions instead of a
+ # copy. We copy it here to prevent it from being modified.
+ d = d.copy()
+ d['id'] = d.get('id', None)
+ if d['action']:
+ url = '%s/%s' % (url, d['action'])
+ d['url'] = url
+ d['category'] = d.get('category', 'object')
+ d['visible'] = d.get('visible', 1)
+ actions.append(d)
+
if hasattr(base, 'listActions'):
self._listActions(append,object,info,ec)
-
# Reorganize the actions by category,
# filtering out disallowed actions.
=== CMF/CMFCore/TypesTool.py 1.38 => 1.39 ===
actions = []
for idx in range(len(self._actions)):
s_idx = str(idx)
- action = {
- 'id': str(properties.get('id_' + s_idx, '')),
- 'name': str(properties.get('name_' + s_idx, '')),
- 'action': str(properties.get('action_' + s_idx, '')),
- 'permissions':
- (properties.get('permission_' + s_idx, ()),),
- 'category': str(properties.get('category_' + s_idx, '')),
- 'visible': not not properties.get('visible_' + s_idx, 0),
- }
+ action = self._actions[idx].copy()
+ action.update( {
+ 'id': str(properties.get('id_' + s_idx, '')),
+ 'name': str(properties.get('name_' + s_idx, '')),
+ 'action': str(properties.get('action_' + s_idx, '')),
+ 'permissions':
+ (properties.get('permission_' + s_idx, ()),),
+ 'category': str(properties.get('category_' + s_idx, '')),
+ 'visible': not not properties.get('visible_' + s_idx, 0),
+ } )
if not action['name']:
raise ValueError('A name is required.')
- actions.append(action)
- self._actions = tuple(actions)
+ actions.append( action )
+ self._actions = tuple( actions )
if REQUEST is not None:
return self.manage_editActionsForm(REQUEST, manage_tabs_message=
'Actions changed.')
@@ -476,6 +477,7 @@
"""
# Get the factory method, performing a security check
# in the process.
+
m = self._getFactoryMethod(container, raise_exc=1)
if m is None: