[Zope-dev] VirtualHostFolder Product (similar to Site objects)

Lalo Martins lalo@webcom.com
Fri, 24 Sep 1999 05:57:00 -0300


On Tue, Sep 21, 1999 at 08:23:26PM -0700, Adam Feuer wrote:
> folks,
> 
>   ok, enclosed is that VirtualHostFolder product i mentioned-- 0.0.1,
> a *very* preliminary release. it does mapping Virtual Hosting by Site
> Name and/or IP address.

I'm trying it out, and already found a bug :-)

Your code assumes HTTP_HOST has a port number. If it doesn't,
the pages just won't display (``unpack list of wrong size'' on
the string.split call).

Quick fix:

--- Remapper.py.orig	Tue Sep 21 22:12:33 1999
+++ Remapper.py	Fri Sep 24 05:50:26 1999
@@ -80,7 +80,12 @@
         # try HTTP/1.1 Host header identification first
         http_host = request.get('HTTP_HOST')
         if http_host != None:
-            requestedSite,requestedPort=string.split(http_host,':')
+            host_info=string.split(http_host,':')
+ 	    requestedSite=host_info[0]
+            if len(host_info)=1
+		requestedPort='80'
+            else:
+		requestedPort=host_info[1]
             #print "remap- requestedSite %s" % requestedSite
             try:
                 path_prefix=self.root[requestedSite]

It's not pretty, but it's how I usually handle string.split.
Perhaps I'll bother Guido about adding a ``minsplit'' parameter
to string.split on a future version.

[]s,
                                               |alo
                                               +----
--
      I am Lalo of deB-org. You will be freed.
                 Resistance is futile.

http://www.webcom.com/lalo      mailto:lalo@webcom.com
                 pgp key in the web page

Debian GNU/Linux       --        http://www.debian.org