[Zope-Checkins] CVS: Zope/lib/python/OFS - Application.py:1.157.4.1 Traversable.py:1.8.20.1
Shane Hathaway
shane@digicool.com
Wed, 26 Sep 2001 17:58:57 -0400
Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv5844
Modified Files:
Tag: ComponentArchitecture-branch
Application.py Traversable.py
Log Message:
Began adding module-level functions for the methods of Traversable.
=== Zope/lib/python/OFS/Application.py 1.157 => 1.157.4.1 ===
web__form__method='GET'
isTopLevelPrincipiaApplicationObject=1
+ _isTopLevelApplicationObject=1
_isBeingUsedAsAMethod_=0
# Create the help system object
=== Zope/lib/python/OFS/Traversable.py 1.8 => 1.8.20.1 ===
from urllib import quote
+from Acquisition import aq_base, aq_get, aq_inner, aq_parent
+
+
_marker=[]
StringType=type('')
+
+
+def getPhysicalRootOf(ob):
+ try:
+ func = aq_get(ob, 'getPhysicalRoot', None, 1)
+ except AttributeError:
+ return ob
+ else:
+ if func is not None:
+ return func()
+ else:
+ return ob
+
+def getPhysicalPathOf(ob):
+ r = []
+ while ob is not None:
+ if getattr(ob, '_isTopLevelApplicationObject', 0):
+ break
+ base = aq_base(ob)
+ # XXX should be looking for "aq_name" or whatever it will be called.
+ if hasattr(base, 'getId'):
+ r.append(ob.getId())
+ elif hasattr(base, '__name__'):
+ r.append(ob.__name__)
+ if hasattr(base, 'im_self'):
+ # SECURITY HOLE: im_self can be impersonated.
+ ob = ob.im_self
+ else:
+ ob = aq_parent(aq_inner(ob))
+ r.append('')
+ r.reverse()
+ return tuple(r)
+
class Traversable: