[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL - AbsoluteURL.py:1.2 __init__.py:1.2 config.zcml:1.2

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:29:51 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL
In directory cvs.zope.org:/tmp/cvs-serv20468/lib/python/Zope/App/ZopePublication/AbsoluteURL

Added Files:
	AbsoluteURL.py __init__.py config.zcml 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.

=== Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/AbsoluteURL.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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
+# 
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from Zope.Proxy.ContextWrapper import getWrapperContainer, getWrapperData
+from Zope.ComponentArchitecture import getView
+
+from Interface import Interface
+
+class IAbsoluteURL(Interface):
+
+    def __str__():
+        """Get a human-readable string representation
+        """
+
+    def __repr__():
+        """Get a string representation
+        """
+    
+
+class AbsoluteURL(BrowserView):
+
+    def __str__(self):
+        context = self.context
+        dict = getWrapperData(context)
+        name = dict and dict.get('name') or None
+        container = getWrapperContainer(context)
+        if name is None or container is None:
+            raise TypeError, 'Not enough context information to get a URL'
+
+        return "%s/%s" % (getView(container, 'absolute_url', self.request),
+                          name)
+
+    __call__ = __str__
+
+
+class SiteAbsoluteURL(BrowserView):
+
+    def __str__(self):
+        return self.request.getApplicationURL()
+
+    __call__ = __str__
+
+
+    
+


=== Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/__init__.py 1.1 => 1.2 ===


=== Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/config.zcml 1.1 => 1.2 ===
+   xmlns='http://namespaces.zope.org/zope'
+   xmlns:security='http://namespaces.zope.org/security'
+   xmlns:browser='http://namespaces.zope.org/browser'
+>
+
+  <browser:view 
+      name="absolute_url"
+      factory=".AbsoluteURL." 
+      permission='Zope.Public'
+      allowed_interface=".AbsoluteURL.IAbsoluteURL"     
+  />
+  
+  <browser:view 
+      for="Zope.App.OFS.Content.Folder.RootFolder.IRootFolder"
+      name="absolute_url"
+      factory=".AbsoluteURL.SiteAbsoluteURL" 
+      permission='Zope.Public'
+      allowed_interface=".AbsoluteURL.IAbsoluteURL"     
+  />
+
+</zopeConfigure>