[Zope3-dev] Re: Make AbsoluteURL produce quoted urls

Philipp von Weitershausen philipp at weitershausen.de
Tue Jun 1 03:53:01 EDT 2004


Bjorn Tillenius wrote:
> > > No, it should still return ASCII strings. It should encode the name to
> > > utf-8 and the quote it (thus producing urls containing %xx:s). 
> > > Actually,
> > > now I'm sure that's the right thing to do, I will fix it tomorrow.
> > 
> > Shouldn't these URL's only be quoted if they are put in a
> > src or href attribute? Only being able to output Unicode URL's
> > as encoded ASCII rather defeats the purpose of them.
> 
> 
> Yes, that's right. Do you have a use case for returning unicode URLs
> instead of ASCII ones?

Because you might not always want to encode in UTF-8. If you'd like to 
display a cyrillic URL to the user in a web page (not in an href), then 
you'd want KR-8 or whatever it is.

> If we return unicode, we have to change every use
> of absolute_url in Zope3. That is, change '<a tal:attributes="href
> context/@@absolute_url">' to something where you quote the URL first. I
> think that justifies returning quoted ASCII URLs, if you want something
> else, you should do something extra.

No, I think there's a quite easy solution. AbsoluteURL.__call__ should 
return unicode so that one has all the options when using it from 
Python. AbsoluteURL.__str__ should return whatever __call__ would 
return, but encoded in UTF8. If I remember correctly, TALES first 
evaluates __str__ before __call__, so the path expressions would still 
be fine.

Philipp



More information about the Zope3-dev mailing list