[Zope3-checkins] CVS: Zope3/src/zope/app - location.py:1.6

Christian Zagrodnick cvs-admin at zope.org
Sun Dec 7 06:31:43 EST 2003


Update of /cvs-repository/Zope3/src/zope/app
In directory cvs.zope.org:/tmp/cvs-serv28276/src/zope/app

Modified Files:
	location.py 
Log Message:
added getNearestSite to IPhysicallyLocatable (and implementations)


=== Zope3/src/zope/app/location.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/location.py:1.5	Thu Nov 20 02:30:31 2003
+++ Zope3/src/zope/app/location.py	Sun Dec  7 06:31:13 2003
@@ -21,6 +21,7 @@
 from zope.app.interfaces.traversing import IPhysicallyLocatable
 from zope.app.interfaces.traversing import IContainmentRoot
 from zope.app.interfaces.traversing import ITraverser
+from zope.app.interfaces.services.service import ISite
 from zope.proxy import removeAllProxies
 from zope.proxy import ProxyBase, getProxiedObject
 from zope.app.decorator import DecoratorSpecificationDescriptor
@@ -198,8 +199,14 @@
         """
         return self.context.__name__
 
-
-
+    def getNearestSite(self):
+        "return the nearest site, see IPhysicallyLocatable"
+        if ISite.isImplementedBy(self.context):
+            return self
+        for parent in zapi.getParents(self.context):
+            if ISite.isImplementedBy(parent):
+                return parent
+        return self.getRoot()
 
 def inside(l1, l2):
     """Is l1 inside l2




More information about the Zope3-Checkins mailing list