[albatross-users] AppContext.redirect_url() question

Matt Goodall matt at pollenation.net
Wed Jul 9 19:06:41 EST 2003


On Tue, 2003-07-08 at 17:29, Matt Goodall wrote:
> I'm probably being really stupid and missing something obvious but this 
> is the bit from redirect_url() I'm confused about:
> 
>         this_path = urlparse.urlparse(self.request.get_uri())[2]
>         base_path = urlparse.urlparse(self.app.base_url())[2]
>         pos = this_path.find(base_path)
>         new_base = this_path[:pos + len(base_path)]
> 
> Firstly, this_path and base_path are normally the same up to the name of 
> the script and so pos will be 0. The only time pos can be non-zero is 
> when the URLs don't match at all or this_path contains an extra path at 
> the start. I can't think of a situation where this_path has the extra path.
> 
> So ... that makes new_base the same as base_path and so I don't 
> understand why you cannot simply add the redirect location to the 
> base_path. You can all humiliate me now and tell me that I can't read 
> simple code if you want ;-).
> 
> My big question is why bother with pos and the this_path slice? What is 
> it needed for?

OK, now I know after reading Sheila's "Upgrade problems" thread. It's
for when base_url is not absolute.

-- 
Matt Goodall, Pollenation Internet Ltd
w: http://www.pollenation.net
e: matt at pollenation.net



More information about the Albatross-users mailing list