Commit 8d28a4f5 authored by Kevin Deldycke's avatar Kevin Deldycke

This patch is based on Products/CMFCore/utils.py file from CMF 1.5.0 package.

Please update the following file if you update CMF to greater version.
The modifications in this method are:
  * new filter on default action (= "action.getCategory().endswith('_%s' % view)" statement)
  * new test on action condition (= "action.testCondition(context)" statement)
This method was patched to let CMF choose between several default actions according conditions.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9598 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 387a8495
No related merge requests found
...@@ -41,6 +41,7 @@ from Products.ERP5Type.patches import ActionProviderBase ...@@ -41,6 +41,7 @@ from Products.ERP5Type.patches import ActionProviderBase
from Products.ERP5Type.patches import CookieCrumbler from Products.ERP5Type.patches import CookieCrumbler
from Products.ERP5Type.patches import Localizer from Products.ERP5Type.patches import Localizer
from Products.ERP5Type.patches import CMFMailIn from Products.ERP5Type.patches import CMFMailIn
from Products.ERP5Type.patches import CMFCoreUtils
# These symbols are required for backward compatibility # These symbols are required for backward compatibility
from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager
......
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
from Products.CMFCore.utils import * from Products.CMFCore.utils import *
from Products.CMFCore import utils from Products.CMFCore.utils import _verifyActionPermissions
from Products.CMFCore import PortalContent
from zLOG import LOG
"""
This patch is based on Products/CMFCore/utils.py file from CMF 1.5.0 package.
Please update the following file if you update CMF to greater version.
The modifications in this method are:
* new filter on default action (= "action.getCategory().endswith('_%s' % view)" statement)
* new test on action condition (= "action.testCondition(context)" statement)
This method was patched to let CMF choose between several default actions according conditions.
"""
security.declarePrivate('_getViewFor') security.declarePrivate('_getViewFor')
def _getViewFor(obj, view='view'): def CMFCoreUtils_getViewFor(obj, view='view'):
warn('__call__() and view() methods using _getViewFor() as well as ' warn('__call__() and view() methods using _getViewFor() as well as '
'_getViewFor() itself are deprecated and will be removed in CMF 1.6. ' '_getViewFor() itself are deprecated and will be removed in CMF 1.6. '
'Bypass these methods by defining \'(Default)\' and \'view\' Method ' 'Bypass these methods by defining \'(Default)\' and \'view\' Method '
...@@ -11,13 +37,12 @@ def _getViewFor(obj, view='view'): ...@@ -11,13 +37,12 @@ def _getViewFor(obj, view='view'):
ti = obj.getTypeInfo() ti = obj.getTypeInfo()
if ti is not None: if ti is not None:
context = getActionContext( obj ) context = getActionContext( obj )
actions = ti.listActions() actions = ti.listActions()
for action in actions: for action in actions:
if action.getId() == view or action.getCategory().endswith('_%s' % view): if action.getId() == view or action.getCategory().endswith('_%s' % view):
if _verifyActionPermissions( obj, action ): if _verifyActionPermissions(obj, action):
if action.testCondition(context):
target = action.action(context).strip() target = action.action(context).strip()
if target.startswith('/'): if target.startswith('/'):
target = target[1:] target = target[1:]
...@@ -28,6 +53,7 @@ def _getViewFor(obj, view='view'): ...@@ -28,6 +53,7 @@ def _getViewFor(obj, view='view'):
# Find something that's allowed. # Find something that's allowed.
for action in actions: for action in actions:
if _verifyActionPermissions(obj, action): if _verifyActionPermissions(obj, action):
if action.testCondition(context):
target = action.action(context).strip() target = action.action(context).strip()
if target.startswith('/'): if target.startswith('/'):
target = target[1:] target = target[1:]
...@@ -41,4 +67,4 @@ def _getViewFor(obj, view='view'): ...@@ -41,4 +67,4 @@ def _getViewFor(obj, view='view'):
'/'.join(obj.getPhysicalPath())) '/'.join(obj.getPhysicalPath()))
utils._getViewFor = _getViewFor PortalContent._getViewFor = CMFCoreUtils_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