[Zope] Publishing a sub-folder in 2.0.0a3

bruce@perens.com bruce@perens.com
1 Jul 1999 19:47:48 -0000


Evan Simpson sent me a fix for publishing a sub-folder, and I have ported
that fix to 2.0.0a3 . Do not apply this patch naively, I've tested it once
and I'm not at all familliar with the internals of Zope. It's posted here for
discussion.

The Apache rewrite rule is changed to add ZOPE_OMIT_STEPS=1 to the environment.
The patch makes ZPublisher chop as many initial pathname elements as
specified in ZOPE_OMIT_STEPS.

	Thanks

	Bruce Perens

# Zope configuration maps / to CGI Zope.cgi/TECHNOCRAT.NET/
RewriteEngine on
RewriteCond %{HTTP:Authorization}  ^(.*)
RewriteRule ^/(.*) /usr/lib/cgi-bin/Zope.cgi/TECHNOCRAT.NET/$1 [last,e=HTTP_CGI_AUTHORIZATION:%1,e=ZOPE_OMIT_STEPS:1,t=application/x-httpd-cgi,l]

	

--- old/Zope-2.0.0a3-src/lib/python/ZPublisher/BaseRequest.py	Thu Mar 18 13:32:35 1999
+++ Zope-2.0.0a3-src/lib/python/ZPublisher/BaseRequest.py	Thu Jul  1 12:18:24 1999
@@ -219,6 +219,13 @@
         else: baseflag=1
         URL=request['URL']
     
+	# The following was added by Bruce Perens on advice of Evan Simpson.
+	omit_steps=request.environ.get('ZOPE_OMIT_STEPS')
+	if omit_steps:
+		omit_steps = int(omit_steps)
+		request['PATH_INFO'] = '/' + join(path[omit_steps:], '/');
+	# End added material.
+
         parents=request['PARENTS']
         object=parents[-1]
         del parents[-1]
@@ -258,7 +265,15 @@
         while path:
             entry_name=path[-1]
             del path[-1]
-            URL="%s/%s" % (URL,quote(entry_name))
+
+	    # The following was changed by Bruce Perens on advice of Evan Simpson
+            # URL="%s/%s" % (URL,quote(entry_name))
+	    if omit_steps:
+		omit_steps = omit_steps - 1
+	    else:
+            	URL="%s/%s" % (URL,quote(entry_name))
+	    # End of changed material.
+
             got=0
             if entry_name:
                 if entry_name[:1]=='_':