Log message for revision 110346:
  Moved the ``absoluteurl`` views into the OFS package.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  A   Zope/trunk/src/OFS/absoluteurl.py
  A   Zope/trunk/src/OFS/absoluteurl.zcml
  U   Zope/trunk/src/Products/Five/browser/absoluteurl.py
  U   Zope/trunk/src/Products/Five/browser/configure.zcml

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst  2010-03-30 23:05:20 UTC (rev 110345)
+++ Zope/trunk/doc/CHANGES.rst  2010-03-30 23:23:32 UTC (rev 110346)
@@ -11,6 +11,8 @@
 Restructuring
 +++++++++++++
 
+- Moved the ``absoluteurl`` views into the OFS package.
+
 - Moved ``testbrowser`` module into the Testing package.
 
 - Moved the code handling ZCML loading into the ``Zope2.App`` package. The

Copied: Zope/trunk/src/OFS/absoluteurl.py (from rev 110303, 
Zope/trunk/src/Products/Five/browser/absoluteurl.py)
===================================================================
--- Zope/trunk/src/OFS/absoluteurl.py                           (rev 0)
+++ Zope/trunk/src/OFS/absoluteurl.py   2010-03-30 23:23:32 UTC (rev 110346)
@@ -0,0 +1,139 @@
+##############################################################################
+#
+# Copyright (c) 2004, 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import urllib
+from Acquisition import aq_parent
+from OFS.interfaces import ITraversable
+
+from zope.component import getMultiAdapter
+from zope.interface import implements
+from zope.traversing.browser.interfaces import IAbsoluteURL
+from zope.traversing.browser.absoluteurl import _insufficientContext, _safe
+from zope.publisher.browser import BrowserView
+
+
+class AbsoluteURL(BrowserView):
+    """An absolute_url adapter for generic objects in Zope 2 that
+    aren't OFS.Traversable (e.g. views, resources, etc.).
+
+    This is very close to the generic implementation from
+    zope.traversing.browser, but the Zope 2 request doesn't support
+    all the methods that it uses yet.
+    """
+    implements(IAbsoluteURL)
+
+    def __unicode__(self):
+        return urllib.unquote(self.__str__()).decode('utf-8')
+
+    def __str__(self):
+        context = self.context
+        request = self.request
+
+        container = aq_parent(context)
+        if container is None:
+            raise TypeError(_insufficientContext)
+
+        url = str(getMultiAdapter((container, request), name='absolute_url'))
+        name = self._getContextName(context)
+        if name is None:
+            raise TypeError(_insufficientContext)
+
+        if name:
+            url += '/' + urllib.quote(name.encode('utf-8'), _safe)
+
+        return url
+
+    __call__ = __str__
+
+    def _getContextName(self, context):
+        if getattr(context, 'getId', None) is not None:
+            return context.getId()
+        return getattr(context, '__name__', None)
+
+    def breadcrumbs(self):
+        context = self.context
+        request = self.request
+
+        # We do this here do maintain the rule that we must be wrapped
+        container = aq_parent(context)
+        if container is None:
+            raise TypeError(_insufficientContext)
+
+        base = tuple(getMultiAdapter((container, request),
+                                     name='absolute_url').breadcrumbs())
+
+        name = self._getContextName(context)
+        if name is None:
+            raise TypeError(_insufficientContext)
+
+        if name:
+            base += ({'name': name,
+                      'url': ("%s/%s" % (base[-1]['url'],
+                                         urllib.quote(name.encode('utf-8'),
+                                                      _safe)))
+                      }, )
+
+        return base
+
+
+class OFSTraversableAbsoluteURL(BrowserView):
+    """An absolute_url adapter for OFS.Traversable subclasses
+    """
+    implements(IAbsoluteURL)
+
+    def __unicode__(self):
+        return urllib.unquote(self.__str__()).decode('utf-8')
+
+    def __str__(self):
+        return self.context.absolute_url()
+
+    __call__ = __str__
+
+    def breadcrumbs(self):
+        context = self.context
+        container = aq_parent(context)
+        request = self.request
+
+        name = context.getId()
+        
+        if (container is None
+            or self._isVirtualHostRoot()
+            or not ITraversable.providedBy(container)):
+            return ({'name': name, 'url': context.absolute_url()},)
+
+        view = getMultiAdapter((container, request), IAbsoluteURL)
+        base = tuple(view.breadcrumbs())
+        base += (
+            {'name': name, 'url': ("%s/%s" % (base[-1]['url'], name))},)
+
+        return base
+
+    def _isVirtualHostRoot(self):
+        virtualrootpath = self.request.get('VirtualRootPhysicalPath', None)
+        if virtualrootpath is None:
+            return False
+        context = self.context
+        return context.restrictedTraverse(virtualrootpath) == context
+
+
+class RootAbsoluteURL(OFSTraversableAbsoluteURL):
+    """An absolute_url adapter for the root object (OFS.Application)
+    """
+    def breadcrumbs(self):
+        context = self.context
+        request = self.request
+
+        return ({'name': context.getId(),
+                 'url': context.absolute_url()
+                 },)

Added: Zope/trunk/src/OFS/absoluteurl.zcml
===================================================================
--- Zope/trunk/src/OFS/absoluteurl.zcml                         (rev 0)
+++ Zope/trunk/src/OFS/absoluteurl.zcml 2010-03-30 23:23:32 UTC (rev 110346)
@@ -0,0 +1,52 @@
+<configure xmlns="http://namespaces.zope.org/zope";
+           xmlns:browser="http://namespaces.zope.org/browser";>
+
+  <browser:page
+      for="*"
+      name="absolute_url"
+      class=".absoluteurl.AbsoluteURL"
+      permission="zope.Public"
+      allowed_interface="zope.traversing.browser.interfaces.IAbsoluteURL"
+      />
+
+  <view
+      for="*"
+      factory=".absoluteurl.AbsoluteURL"
+      type="zope.publisher.interfaces.http.IHTTPRequest"
+      permission="zope.Public"
+      provides="zope.traversing.browser.interfaces.IAbsoluteURL"
+      />
+
+  <browser:page
+      for=".interfaces.ITraversable"
+      name="absolute_url"
+      class=".absoluteurl.OFSTraversableAbsoluteURL"
+      permission="zope.Public"
+      allowed_interface="zope.traversing.browser.interfaces.IAbsoluteURL"
+      />
+
+  <view
+      for=".interfaces.ITraversable"
+      factory=".absoluteurl.OFSTraversableAbsoluteURL"
+      type="zope.publisher.interfaces.http.IHTTPRequest"
+      permission="zope.Public"
+      provides="zope.traversing.browser.interfaces.IAbsoluteURL"
+      />
+
+  <browser:page
+      for=".interfaces.IApplication"
+      name="absolute_url"
+      class=".absoluteurl.RootAbsoluteURL"
+      permission="zope.Public"
+      allowed_interface="zope.traversing.browser.interfaces.IAbsoluteURL"
+      />
+
+  <view
+      for=".interfaces.IApplication"
+      factory=".absoluteurl.RootAbsoluteURL"
+      type="zope.publisher.interfaces.http.IHTTPRequest"
+      permission="zope.Public"
+      provides="zope.traversing.browser.interfaces.IAbsoluteURL"
+      />
+
+</configure>


Property changes on: Zope/trunk/src/OFS/absoluteurl.zcml
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: Zope/trunk/src/Products/Five/browser/absoluteurl.py
===================================================================
--- Zope/trunk/src/Products/Five/browser/absoluteurl.py 2010-03-30 23:05:20 UTC 
(rev 110345)
+++ Zope/trunk/src/Products/Five/browser/absoluteurl.py 2010-03-30 23:23:32 UTC 
(rev 110346)
@@ -11,131 +11,11 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Absolute URL
 
-$Id$
-"""
-import urllib
-from Acquisition import aq_inner, aq_parent
-from OFS.interfaces import ITraversable
+from zope.deferredimport import deprecated
 
-from zope.interface import implements
-from zope.component import getMultiAdapter
-from zope.traversing.browser.interfaces import IAbsoluteURL
-from zope.traversing.browser.absoluteurl import _insufficientContext, _safe
-
-from Products.Five.browser import BrowserView
-
-class AbsoluteURL(BrowserView):
-    """An absolute_url adapter for generic objects in Zope 2 that
-    aren't OFS.Traversable (e.g. views, resources, etc.).
-
-    This is very close to the generic implementation from
-    zope.traversing.browser, but the Zope 2 request doesn't support
-    all the methods that it uses yet.
-    """
-    implements(IAbsoluteURL)
-
-    def __unicode__(self):
-        return urllib.unquote(self.__str__()).decode('utf-8')
-
-    def __str__(self):
-        context = self.context
-        request = self.request
-
-        container = aq_parent(context)
-        if container is None:
-            raise TypeError(_insufficientContext)
-
-        url = str(getMultiAdapter((container, request), name='absolute_url'))
-        name = self._getContextName(context)
-        if name is None:
-            raise TypeError(_insufficientContext)
-
-        if name:
-            url += '/' + urllib.quote(name.encode('utf-8'), _safe)
-
-        return url
-
-    __call__ = __str__
-
-    def _getContextName(self, context):
-        if getattr(context, 'getId', None) is not None:
-            return context.getId()
-        return getattr(context, '__name__', None)
-
-    def breadcrumbs(self):
-        context = self.context
-        request = self.request
-
-        # We do this here do maintain the rule that we must be wrapped
-        container = aq_parent(context)
-        if container is None:
-            raise TypeError(_insufficientContext)
-
-        base = tuple(getMultiAdapter((container, request),
-                                     name='absolute_url').breadcrumbs())
-
-        name = self._getContextName(context)
-        if name is None:
-            raise TypeError(_insufficientContext)
-
-        if name:
-            base += ({'name': name,
-                      'url': ("%s/%s" % (base[-1]['url'],
-                                         urllib.quote(name.encode('utf-8'),
-                                                      _safe)))
-                      }, )
-
-        return base
-
-class OFSTraversableAbsoluteURL(BrowserView):
-    """An absolute_url adapter for OFS.Traversable subclasses
-    """
-    implements(IAbsoluteURL)
-
-    def __unicode__(self):
-        return urllib.unquote(self.__str__()).decode('utf-8')
-
-    def __str__(self):
-        context = aq_inner(self.context)
-        return context.absolute_url()
-
-    __call__ = __str__
-
-    def breadcrumbs(self):
-        context = aq_inner(self.context)
-        container = aq_parent(context)
-        request = self.request
-
-        name = context.getId()
-        
-        if (container is None
-            or self._isVirtualHostRoot()
-            or not ITraversable.providedBy(container)):
-            return ({'name': name, 'url': context.absolute_url()},)
-
-        view = getMultiAdapter((container, request), IAbsoluteURL)
-        base = tuple(view.breadcrumbs())
-        base += (
-            {'name': name, 'url': ("%s/%s" % (base[-1]['url'], name))},)
-
-        return base
-
-    def _isVirtualHostRoot(self):
-        virtualrootpath = self.request.get('VirtualRootPhysicalPath', None)
-        if virtualrootpath is None:
-            return False
-        context = aq_inner(self.context)
-        return context.restrictedTraverse(virtualrootpath) == context
-
-class RootAbsoluteURL(OFSTraversableAbsoluteURL):
-    """An absolute_url adapter for the root object (OFS.Application)
-    """
-    def breadcrumbs(self):
-        context = self.context
-        request = self.request
-
-        return ({'name': context.getId(),
-                 'url': context.absolute_url()
-                 },)
+deprecated("Please import from OFS.absoluteurl",
+    AbsoluteURL = 'OFS.absoluteurl:AbsoluteURL',
+    OFSTraversableAbsoluteURL = 'OFS.absoluteurl:OFSTraversableAbsoluteURL',
+    RootAbsoluteURL = 'OFS.absoluteurl:RootAbsoluteURL',
+)

Modified: Zope/trunk/src/Products/Five/browser/configure.zcml
===================================================================
--- Zope/trunk/src/Products/Five/browser/configure.zcml 2010-03-30 23:05:20 UTC 
(rev 110345)
+++ Zope/trunk/src/Products/Five/browser/configure.zcml 2010-03-30 23:23:32 UTC 
(rev 110346)
@@ -5,54 +5,8 @@
       interface="zope.browsermenu.interfaces.IMenuItemType"
       />
 
-  <browser:page
-      for="*"
-      name="absolute_url"
-      class=".absoluteurl.AbsoluteURL"
-      permission="zope.Public"
-      allowed_interface="zope.traversing.browser.interfaces.IAbsoluteURL"
-      />
+  <include package="OFS" file="absoluteurl.zcml"/>
 
-  <view
-      for="*"
-      factory=".absoluteurl.AbsoluteURL"
-      type="zope.publisher.interfaces.http.IHTTPRequest"
-      permission="zope.Public"
-      provides="zope.traversing.browser.interfaces.IAbsoluteURL"
-      />
-
-  <browser:page
-      for="OFS.interfaces.ITraversable"
-      name="absolute_url"
-      class=".absoluteurl.OFSTraversableAbsoluteURL"
-      permission="zope.Public"
-      allowed_interface="zope.traversing.browser.interfaces.IAbsoluteURL"
-      />
-
-  <view
-      for="OFS.interfaces.ITraversable"
-      factory=".absoluteurl.OFSTraversableAbsoluteURL"
-      type="zope.publisher.interfaces.http.IHTTPRequest"
-      permission="zope.Public"
-      provides="zope.traversing.browser.interfaces.IAbsoluteURL"
-      />
-
-  <browser:page
-      for="OFS.interfaces.IApplication"
-      name="absolute_url"
-      class=".absoluteurl.RootAbsoluteURL"
-      permission="zope.Public"
-      allowed_interface="zope.traversing.browser.interfaces.IAbsoluteURL"
-      />
-
-  <view
-      for="OFS.interfaces.IApplication"
-      factory=".absoluteurl.RootAbsoluteURL"
-      type="zope.publisher.interfaces.http.IHTTPRequest"
-      permission="zope.Public"
-      provides="zope.traversing.browser.interfaces.IAbsoluteURL"
-      />
-
   <browser:view
       for="OFS.interfaces.IObjectManager"
       name="+"

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
https://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to