[Zope3-checkins] CVS: Zope3/lib/python/Zope/Publisher/Browser - BrowserResponse.py:1.5

Jim Fulton jim@zope.com
Tue, 1 Oct 2002 08:49:09 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/Browser
In directory cvs.zope.org:/tmp/cvs-serv18475/lib/python/Zope/Publisher/Browser

Modified Files:
	BrowserResponse.py 
Log Message:
Added a new view, 'SelectedManagementView', that redirects to the first
view that a user can access. Changed between-object navigation urls,
like those in breadcrumbs and the contents management view, to use
this view.  This corresponds to Zope 2's 'manage_workspace' method.

Changes the name of the folder contents management view to
'contents.html'. Added a new 'index.html' view as the default view for
folders. If the folder contains an object named 'index.html', then the
view redirects to that object. Otherwise, the view displays a folder
listing with linds to folder items.

Changed the view order for a number of content types so that
management views come before the default view.  This means you can now
traverse to a file or page template from a contents listing and get an
editing view.



=== Zope3/lib/python/Zope/Publisher/Browser/BrowserResponse.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/Publisher/Browser/BrowserResponse.py:1.4	Fri Jun 14 15:22:43 2002
+++ Zope3/lib/python/Zope/Publisher/Browser/BrowserResponse.py	Tue Oct  1 08:49:09 2002
@@ -26,6 +26,7 @@
 
 start_of_header_search=re.compile('(<head[^>]*>)', re.IGNORECASE).search
 base_re_search=re.compile('(<base.*?>)',re.I).search
+isRelative = re.compile("[-_.!~*a-zA-z0-9'()@&=+$,]+(/|$)").match
 
 
 class BrowserResponse(HTTPResponse):
@@ -97,13 +98,19 @@
     def setBase(self, base):
         self._base = base
 
+    def redirect(self, uri):
+        base = getattr(self, '_base', '')
+        if isRelative(uri) and base:
+            l = base.rfind('/')
+            if l >= 0:
+                base = base[:l+1]
+            else:
+                base += '/'
+            uri = base + uri
+
+        super(BrowserResponse, self).redirect(uri)
+
 
-#latin1_alias_match = re.compile(
-#    r'text/html(\s*;\s*charset=((latin)|(latin[-_]?1)|'
-#    r'(cp1252)|(cp819)|(csISOLatin1)|(IBM819)|(iso-ir-100)|'
-#    r'(iso[-_]8859[-_]1(:1987)?)))?$',re.I).match
 
 def is_text_html(content_type):
-    return content_type.startswith('text/html') # or
-#    return (content_type == 'text/html' or
-#            latin1_alias_match(content_type) is not None)
+    return content_type.startswith('text/html')