Commit 9aa6bf88 authored by Hanno Schlichting's avatar Hanno Schlichting

Optimized the `OFS.Traversable.getPhysicalPath` method to avoid excessive...

Optimized the `OFS.Traversable.getPhysicalPath` method to avoid excessive amounts of method calls. Thx to Nikolay Kim from Enfold
parent b8c4aeaa
......@@ -19,6 +19,9 @@ Bugs Fixed
Features Added
++++++++++++++
- Optimized the `OFS.Traversable.getPhysicalPath` method to avoid excessive
amounts of method calls.
- During startup open a connection to every configured database, to ensure all
of them can indeed be accessed. This avoids surprises during runtime when
traversal to some database mountpoint could fail as the underlying storage
......
......@@ -114,13 +114,46 @@ class Traversable:
access this object again later, for example in a copy/paste operation.
getPhysicalRoot() and getPhysicalPath() are designed to operate
together.
This implementation is optimized to avoid excessive amounts of function
calls while walking up from an object on a deep level.
"""
path = (self.getId(),)
try:
id = self.id
except AttributeError:
id = self.getId()
else:
if id is None:
id = self.getId()
p = aq_parent(aq_inner(self))
if p is None:
return (id, )
if p is not None:
path = p.getPhysicalPath() + path
path = [id]
func = self.getPhysicalPath.im_func
while p is not None:
if func is p.getPhysicalPath.im_func:
try:
pid = p.id
except AttributeError:
pid = p.getId()
else:
if pid is None:
pid = p.getId()
path.insert(0, pid)
try:
p = p.__parent__
except AttributeError:
p = None
else:
if IApplication.providedBy(p):
path.insert(0, '')
path = tuple(path)
else:
path = p.getPhysicalPath() + tuple(path)
break
return path
......
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