[Zope3-checkins] CVS: Zope3/src/zope/app/traversing/browser - __init__.py:1.5

Jim Fulton jim at zope.com
Tue Apr 27 06:53:49 EDT 2004


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

Modified Files:
	__init__.py 
Log Message:
Moved the absolute url code into a named module (rather than __init__)


=== Zope3/src/zope/app/traversing/browser/__init__.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/traversing/browser/__init__.py:1.4	Fri Mar 19 15:26:37 2004
+++ Zope3/src/zope/app/traversing/browser/__init__.py	Tue Apr 27 06:53:48 2004
@@ -15,111 +15,6 @@
 
 $Id$
 """
-from zope.interface import implements
-from zope.app.publisher.browser import BrowserView
-from zope.proxy import sameProxiedObjects
 
-from zope.app import zapi
-from zope.app.i18n import ZopeMessageIDFactory as _
-from zope.app.traversing.browser.interfaces import IAbsoluteURL
-
-_insufficientContext = _("There isn't enough context to get URL information. "
-                       "This is probably due to a bug in setting up location "
-                       "information.")
-
-
-class AbsoluteURL(BrowserView):
-    implements(IAbsoluteURL)
-
-    def __str__(self):
-        context = self.context
-        request = self.request
-
-
-        # The application URL contains all the namespaces that are at the
-        # beginning of the URL, such as skins, virtual host specifications and
-        # so on.
-        if sameProxiedObjects(context, request.getVirtualHostRoot()):
-            return request.getApplicationURL()
-
-        container = getattr(context, '__parent__', None)
-        if container is None:
-            raise TypeError, _insufficientContext
-
-        url = str(zapi.getView(container, 'absolute_url', request))
-
-        name = getattr(context, '__name__', None)
-        if name is None:
-            raise TypeError, _insufficientContext
-
-        if name:
-            url += '/'+name
-
-        return url
-
-    __call__ = __str__
-
-    def breadcrumbs(self):
-        context = self.context
-        request = self.request
-
-        # We do this here do maintain the rule that we must be wrapped
-        container = getattr(context, '__parent__', None)
-        if container is None:
-            raise TypeError, _insufficientContext
-
-        if sameProxiedObjects(context, request.getVirtualHostRoot()) or \
-               isinstance(context, Exception):
-            return ({'name':'', 'url': self.request.getApplicationURL()}, )
-
-        base = tuple(zapi.getView(container,
-                                  'absolute_url', request).breadcrumbs())
-
-        name = getattr(context, '__name__', None)
-        if name is None:
-            raise TypeError, _insufficientContext
-
-        if name:
-            base += ({'name': name,
-                      'url': ("%s/%s" % (base[-1]['url'], name))
-                      }, )
-
-        return base
-
-class SiteAbsoluteURL(BrowserView):
-    implements(IAbsoluteURL)
-
-    def __str__(self):
-        context = self.context
-        request = self.request
-
-        if sameProxiedObjects(context, request.getVirtualHostRoot()):
-            return request.getApplicationURL()
-
-        url = request.getApplicationURL()
-
-        name = getattr(context, '__name__', None)
-        if name:
-            url += '/'+name
-
-        return url
-
-    __call__ = __str__
-
-    def breadcrumbs(self):
-        context = self.context
-        request = self.request
-
-        if sameProxiedObjects(context, request.getVirtualHostRoot()):
-            return ({'name':'', 'url': self.request.getApplicationURL()}, )
-
-        base = ({'name':'', 'url': self.request.getApplicationURL()}, )
-
-
-        name = getattr(context, '__name__', None)
-        if name:
-            base += ({'name': name,
-                      'url': ("%s/%s" % (base[-1]['url'], name))
-                      }, )
-
-        return base
+from zope.app.traversing.browser.absoluteurl import AbsoluteURL
+from zope.app.traversing.browser.absoluteurl import SiteAbsoluteURL




More information about the Zope3-Checkins mailing list