Commit d63480c0 authored by Julien Muchembled's avatar Julien Muchembled

Speed up ERP5Type.Utils.createExpressionContext and remove 'folder' from context

folder/folder_url have no clear definition and are not used in ERP5.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29697 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6ee293f3
...@@ -1134,52 +1134,30 @@ def createExpressionContext(object, portal=None): ...@@ -1134,52 +1134,30 @@ def createExpressionContext(object, portal=None):
""" """
Return a context used for evaluating a TALES expression. Return a context used for evaluating a TALES expression.
""" """
if portal is None and object is not None: if object is None:
portal = object.getPortalObject() object_url = ''
if object is None or getattr(object, 'aq_base', None) is None:
folder = portal
else: else:
folder = object object_url = object.absolute_url()
# Search up the containment hierarchy until we find an if portal is None:
# object that claims it's a folder. portal = object.getPortalObject()
while folder is not None:
if getattr(aq_base(folder), 'isPrincipiaFolderish', 0):
# found it.
break
else:
folder = aq_parent(aq_inner(folder))
if portal is not None: if portal is not None:
pm = getToolByName(portal, 'portal_membership') portal_url = portal.absolute_url()
pm = portal.portal_membership
if pm.isAnonymousUser(): if pm.isAnonymousUser():
member = None member = None
else: else:
member = pm.getAuthenticatedMember() member = pm.getAuthenticatedMember()
else: else:
member = None
if object is None:
object_url = ''
else:
object_url = object.absolute_url()
if folder is None:
folder_url = ''
else:
folder_url = folder.absolute_url()
if portal is None:
portal_url = '' portal_url = ''
else: member = None
portal_url = portal.absolute_url()
data = { data = {
'object_url': object_url, 'object_url': object_url,
'folder_url': folder_url,
'portal_url': portal_url, 'portal_url': portal_url,
'object': object, 'object': object,
'folder': folder, 'folder': None, # XXX to be removed when
# ERP5Type.Core.ActionInformation is cleaned up
'portal': portal, 'portal': portal,
'nothing': None, 'nothing': None,
'request': getattr( object, 'REQUEST', None ), 'request': getattr( object, 'REQUEST', None ),
......
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