From d63480c0ea84917e85be11693b951048b23cb7f6 Mon Sep 17 00:00:00 2001 From: Julien Muchembled <jm@nexedi.com> Date: Thu, 15 Oct 2009 23:21:01 +0000 Subject: [PATCH] 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 --- product/ERP5Type/Utils.py | 42 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py index 883593a0b1..e97d284b8c 100644 --- a/product/ERP5Type/Utils.py +++ b/product/ERP5Type/Utils.py @@ -1134,52 +1134,30 @@ def createExpressionContext(object, portal=None): """ Return a context used for evaluating a TALES expression. """ - if portal is None and object is not None: - portal = object.getPortalObject() - - if object is None or getattr(object, 'aq_base', None) is None: - folder = portal + if object is None: + object_url = '' else: - folder = object - # Search up the containment hierarchy until we find an - # object that claims it's a folder. - while folder is not None: - if getattr(aq_base(folder), 'isPrincipiaFolderish', 0): - # found it. - break - else: - folder = aq_parent(aq_inner(folder)) + object_url = object.absolute_url() + if portal is None: + portal = object.getPortalObject() if portal is not None: - pm = getToolByName(portal, 'portal_membership') + portal_url = portal.absolute_url() + pm = portal.portal_membership if pm.isAnonymousUser(): member = None else: member = pm.getAuthenticatedMember() 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 = '' - else: - portal_url = portal.absolute_url() + member = None data = { 'object_url': object_url, - 'folder_url': folder_url, 'portal_url': portal_url, 'object': object, - 'folder': folder, + 'folder': None, # XXX to be removed when + # ERP5Type.Core.ActionInformation is cleaned up 'portal': portal, 'nothing': None, 'request': getattr( object, 'REQUEST', None ), -- 2.30.9