Commit e848f140 authored by Kevin Deldycke's avatar Kevin Deldycke

CMF 1.5.0 provide _getViewFor() method which we can use instead of the...

CMF 1.5.0 provide _getViewFor() method which we can use instead of the _getListFor() method from Utils2.py

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9536 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e88177d4
...@@ -34,8 +34,9 @@ from AccessControl.Permission import pname, Permission ...@@ -34,8 +34,9 @@ from AccessControl.Permission import pname, Permission
from Acquisition import aq_base, aq_inner, aq_acquire, aq_chain from Acquisition import aq_base, aq_inner, aq_acquire, aq_chain
from Products.CMFCore.PortalContent import PortalContent from Products.CMFCore.PortalContent import PortalContent
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.utils import _getViewFor
from Products.DCWorkflow.Transitions import TRIGGER_WORKFLOW_METHOD from Products.DCWorkflow.Transitions import TRIGGER_WORKFLOW_METHOD
...@@ -45,7 +46,6 @@ from Products.ERP5Type import Permissions ...@@ -45,7 +46,6 @@ from Products.ERP5Type import Permissions
from Products.ERP5Type.Utils import UpperCase from Products.ERP5Type.Utils import UpperCase
from Products.ERP5Type.Utils import convertToUpperCase, convertToMixedCase from Products.ERP5Type.Utils import convertToUpperCase, convertToMixedCase
from Products.ERP5Type.Utils import createExpressionContext from Products.ERP5Type.Utils import createExpressionContext
from Products.ERP5Type.Utils2 import _getListFor
from Products.ERP5Type.Accessor.TypeDefinition import list_types from Products.ERP5Type.Accessor.TypeDefinition import list_types
from Products.ERP5Type.Accessor import Base as BaseAccessor from Products.ERP5Type.Accessor import Base as BaseAccessor
from Products.ERP5Type.XMLExportImport import Base_asXML from Products.ERP5Type.XMLExportImport import Base_asXML
...@@ -1123,7 +1123,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -1123,7 +1123,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
Returns the title or the id of the parent Returns the title or the id of the parent
""" """
return self.aq_inner.aq_parent.getTitleOrId() return self.aq_inner.aq_parent.getTitleOrId()
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getParentRelativeUrl' ) 'getParentRelativeUrl' )
def getParentRelativeUrl(self): def getParentRelativeUrl(self):
...@@ -1666,7 +1666,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -1666,7 +1666,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
''' '''
Returns the default list even if folder_contents is overridden. Returns the default list even if folder_contents is overridden.
''' '''
list_action = _getListFor(self) list_action = _getViewFor(self, view='list')
if getattr(aq_base(list_action), 'isDocTemp', 0): if getattr(aq_base(list_action), 'isDocTemp', 0):
return apply(list_action, (self, self.REQUEST),reset=reset) return apply(list_action, (self, self.REQUEST),reset=reset)
else: else:
......
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
#
# Based on: utils.py in CMFCore
#
##############################################################################
from AccessControl import ModuleSecurityInfo
from Products.CMFCore.utils import _verifyActionPermissions, getActionContext
security = ModuleSecurityInfo( 'Products.ERP5.UI.Utils' )
security.declarePrivate('_getListFor')
def _getListFor(obj, view='list'):
ti = obj.getTypeInfo()
if ti is not None:
context = getActionContext( obj )
actions = ti.listActions()
for action in actions:
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):
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