Commit 16698b21 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

* this implementation of getPortalObject() seems a little bit faster than previous one with cache.

* getRootDocumentPath() returns itself instead of None if no root domument.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19649 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b23b4194
...@@ -1759,20 +1759,7 @@ class Base( CopyContainer, ...@@ -1759,20 +1759,7 @@ class Base( CopyContainer,
""" """
Returns the portal object Returns the portal object
""" """
cache = getReadOnlyTransactionCache(self) return self.aq_inner.aq_parent.getPortalObject()
if cache is not None:
key = 'getPortalObject'
try:
return cache[key]
except KeyError:
pass
result = self.portal_url.getPortalObject()
if cache is not None:
cache[key] = result
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowIds') security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowIds')
def getWorkflowIds(self): def getWorkflowIds(self):
...@@ -2708,15 +2695,10 @@ class Base( CopyContainer, ...@@ -2708,15 +2695,10 @@ class Base( CopyContainer,
recursiveReindexObject = reindexObject recursiveReindexObject = reindexObject
def getRootDocumentPath(self): def getRootDocumentPath(self):
# if document, return the path of its root document # Return the path of its root document, or itself if no root document.
# otherwire, return None
self_path_list = self.getPhysicalPath() self_path_list = self.getPhysicalPath()
self_depth = len(self_path_list)
portal_depth = len(self.getPortalObject().getPhysicalPath()) portal_depth = len(self.getPortalObject().getPhysicalPath())
if self_depth > portal_depth + 1: return '/'.join(self_path_list[:portal_depth+2])
return '/'.join(self_path_list[:portal_depth + 2])
else:
return None
security.declareProtected( Permissions.AccessContentsInformation, 'getIndexableChildValueList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getIndexableChildValueList' )
def getIndexableChildValueList(self): def getIndexableChildValueList(self):
......
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