[Zope-dev] VirtualHostFolder Product (similar to Site objects)
Andreas Kostyrka
andreas@mtg.co.at
Fri, 24 Sep 1999 12:13:41 +0200 (CEST)
On Fri, 24 Sep 1999, Lalo Martins wrote:
> 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]
What about:
if not ':' in http_host: http_host=http_host+":80"
requestedSite,requestedPort=string.split(http_host,':',1)
string.atoi(requestedPort) # verify that the port is numeric.
Andreas
--
Andreas Kostyrka | andreas@mtg.co.at
phone: +43/1/7070750 | phone: +43/676/4091256
MTG Handelsges.m.b.H. | fax: +43/1/7065299
Raiffeisenstr. 16/9 | 2320 Zwoelfaxing AUSTRIA