Commit b374861f authored by Jean-Paul Smets's avatar Jean-Paul Smets

updated for CMF1.4


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@117 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 57b9a344
......@@ -28,22 +28,37 @@ from Products.CMFCore.utils import _verifyActionPermissions
security = ModuleSecurityInfo( 'Products.ERP5.UI.Utils' )
security.declarePrivate('_getListFor')
security.declarePrivate('_getViewFor')
def _getListFor(obj, view='list'):
ti = obj.getTypeInfo()
if ti is not None:
actions = ti.getActions()
context = getActionContext( obj )
actions = ti.listActions()
for action in actions:
if action.get('id', None) == view:
if _verifyActionPermissions(obj, action):
return obj.restrictedTraverse(action['action'])
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):
return obj.restrictedTraverse(action['action'])
target = action.action(context).strip()
if target.startswith('/'):
target = target[1:]
__traceback_info__ = ( ti.getId(), target )
return obj.restrictedTraverse( target )
raise 'Unauthorized', ('No accessible views available for %s' %
'/'.join(obj.getPhysicalPath()))
else:
raise 'Not Found', ('Cannot find default view for "%s"' %
'/'.join(obj.getPhysicalPath()))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment