[Zope] Subsiting.

Andreas Kostyrka andreas@mtg.co.at
Thu, 1 Jul 1999 18:15:08 +0200 (CEST)


Hi!

I've created a subsite patch for Zope 2.0.0a3.
The usage is easy, just add a E=ZOPE_DROP_FOLDER:num, to the RewriteRule,
where n is the number of ids to drop.

So for example, the following RewriteRule is correct:
<VH www.photoderm.at>
...
RewriteRule ^/(.*)
/home/httpd/htdocs/cgi/mtg/mtg.cgi/sites/photoderm.at/$1
[e=HTTP_CGI_AUTHORIZATION:%1,E=ZOPE_DROP_FOLDER:2,t=application/x-httpd-cgi,l]
...
</VH>

This way, Zope drops 2 folders (/sites/photoderm.at) in the beginning.

Something like this should probably be included with the standard
distribution. This patch doesn't change a thing in the normal path
processing, it does munge the REQUEST only when ZOPE_DROP_FOLDER is
activated.

Andreas

diff -uNr Zope-2.0.0a3-src.org/lib/python/ZPublisher/BaseRequest.py Zope-2.0.0a3-src/lib/python/ZPublisher/BaseRequest.py
--- Zope-2.0.0a3-src.org/lib/python/ZPublisher/BaseRequest.py	Thu Mar 18 22:32:35 1999
+++ Zope-2.0.0a3-src/lib/python/ZPublisher/BaseRequest.py	Thu Jul  1 15:24:41 1999
@@ -84,7 +84,7 @@
 ##############################################################################
 __version__='$Revision: 1.8 $'[11:-2]
 
-from string import join, split, find, rfind, lower, upper
+from string import join, split, find, rfind, lower, upper, atoi
 from urllib import quote
 
 UNSPECIFIED_ROLES=''
@@ -218,6 +218,10 @@
             method='index_html'
         else: baseflag=1
         URL=request['URL']
+	if request.environ.has_key('ZOPE_DROP_FOLDER'):
+		dropfolder=atoi(request.environ["ZOPE_DROP_FOLDER"])
+	else:
+		dropfolder=0
     
         parents=request['PARENTS']
         object=parents[-1]
@@ -258,7 +262,10 @@
         while path:
             entry_name=path[-1]
             del path[-1]
-            URL="%s/%s" % (URL,quote(entry_name))
+	    if dropfolder==0:
+                URL="%s/%s" % (URL,quote(entry_name))
+	    else:
+		dropfolder=dropfolder-1
             got=0
             if entry_name:
                 if entry_name[:1]=='_':

-- 
Win95: n., A huge annoying boot virus that causes random spontaneous system
     crashes, usually just before saving a massive project.  Easily cured by
     UNIX.  See also MS-DOS, IBM-DOS, DR-DOS, Win 3.x, Win98.