[Erp5-report] r9565 - /erp5/trunk/products/ERP5Type/patches/CMFCoreUtils.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Aug 30 18:44:36 CEST 2006
Author: jp
Date: Wed Aug 30 18:44:32 2006
New Revision: 9565
URL: http://svn.erp5.org?rev=9565&view=rev
Log:
Initial upload
Added:
erp5/trunk/products/ERP5Type/patches/CMFCoreUtils.py
Added: erp5/trunk/products/ERP5Type/patches/CMFCoreUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/CMFCoreUtils.py?rev=9565&view=auto
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/CMFCoreUtils.py (added)
+++ erp5/trunk/products/ERP5Type/patches/CMFCoreUtils.py Wed Aug 30 18:44:32 2006
@@ -1,0 +1,44 @@
+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
More information about the Erp5-report
mailing list