Commit 039e340e authored by Jean-Paul Smets's avatar Jean-Paul Smets

Initial upload

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9565 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 51b0f0f7
from Products.CMFCore.utils import *
from Products.CMFCore import utils
security.declarePrivate('_getViewFor')
def _getViewFor(obj, view='view'):
warn('__call__() and view() methods using _getViewFor() as well as '
'_getViewFor() itself are deprecated and will be removed in CMF 1.6. '
'Bypass these methods by defining \'(Default)\' and \'view\' Method '
'Aliases.',
DeprecationWarning)
ti = obj.getTypeInfo()
if ti is not None:
context = getActionContext( obj )
actions = ti.listActions()
for action in actions:
if action.getId() == view or action.getCategory().endswith('_%s' % 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):
target = action.action(context).strip()
if target.startswith('/'):
target = target[1:]
__traceback_info__ = ( ti.getId(), target )
return obj.restrictedTraverse( target )
raise AccessControl_Unauthorized( 'No accessible views available for '
'%s' % '/'.join( obj.getPhysicalPath() ) )
else:
raise NotFound('Cannot find default view for "%s"' %
'/'.join(obj.getPhysicalPath()))
utils._getViewFor = _getViewFor
\ No newline at end of file
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