[albatross-users] How to get https protocol from al-a tags?

Andrew McNamara andrewm at object-craft.com.au
Wed Jan 14 15:19:15 EST 2004


>where it's going on.  You could change the http to https, but really IMHO
>albatross shouldn't be putting http(s) and servername into a url,

I agree.

>prefixing with '/' at the beginning is a lot easier to move between sites.
>I've also done sites with wildcards for dns and servername, and this would
>be a problem here too.  I don't know what the gain is for building the
>full url, so there maybe a reason to have it, but changing it to:

That's a good question - I don't know the answer, which it makes me
nervous to change it.

>    def redirect_url(self, loc): return self.absolute_base_url() + loc 
>
>should solve your problem, but that's untested so you may need to test it
>a bit.

The following is more complex, but I think the result is more consistent
(certainly than the original implementation):

    def redirect_url(self, loc):
        scheme, netloc, path = urlparse.urlparse(loc)[:3]
        if scheme or netloc:
            return loc                  # Already absolute
        scheme, netloc, path = self._parse_current_uri()
        if loc.startswith('/'):
            return urlparse.urlunparse((scheme, netloc, loc, '', '', ''))
        new_base = self.absolute_base_url()
        if new_base[-1] != '/':
            new_base = new_base + '/'
        return urlparse.urlunparse((scheme, netloc, new_base + loc, '', '', ''))

I'll include this in the next snapshot, as well as some tests for it.

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/



More information about the Albatross-users mailing list