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

Fixed the problem of mutliple view.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10374 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e39f8c81
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
from Products.CMFCore.utils import * from Products.CMFCore.utils import *
from Products.CMFCore.utils import _verifyActionPermissions from Products.CMFCore.utils import _verifyActionPermissions
from Products.CMFCore.Expression import getExprContext
from Products.CMFCore import PortalContent from Products.CMFCore import PortalContent
from zLOG import LOG from zLOG import LOG
...@@ -27,7 +28,6 @@ from zLOG import LOG ...@@ -27,7 +28,6 @@ from zLOG import LOG
This method was patched to let CMF choose between several default actions according conditions. This method was patched to let CMF choose between several default actions according conditions.
""" """
security.declarePrivate('_getViewFor')
def CMFCoreUtils_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. '
...@@ -37,12 +37,15 @@ def CMFCoreUtils_getViewFor(obj, view='view'): ...@@ -37,12 +37,15 @@ def CMFCoreUtils_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 )
test_context = getExprContext(obj, obj) # Patch 1: mimic _listActionInfos in ActionsTool
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):
# Patch 2: consider anything ending by _view
if _verifyActionPermissions(obj, action): if _verifyActionPermissions(obj, action):
if action.testCondition(context) and action.visible: if action.visible and action.testCondition(test_context): # Patch 3: test actions
target = action.action(context).strip() target = action.action(context).strip()
if target.startswith('/'): if target.startswith('/'):
target = target[1:] target = target[1:]
...@@ -53,7 +56,7 @@ def CMFCoreUtils_getViewFor(obj, view='view'): ...@@ -53,7 +56,7 @@ def CMFCoreUtils_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): if action.visible and action.testCondition(test_context): # Patch 3: test actions
target = action.action(context).strip() target = action.action(context).strip()
if target.startswith('/'): if target.startswith('/'):
target = target[1:] target = target[1:]
...@@ -66,5 +69,4 @@ def CMFCoreUtils_getViewFor(obj, view='view'): ...@@ -66,5 +69,4 @@ def CMFCoreUtils_getViewFor(obj, view='view'):
raise NotFound('Cannot find default view for "%s"' % raise NotFound('Cannot find default view for "%s"' %
'/'.join(obj.getPhysicalPath())) '/'.join(obj.getPhysicalPath()))
PortalContent._getViewFor = CMFCoreUtils_getViewFor PortalContent._getViewFor = CMFCoreUtils_getViewFor
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