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

Bjorn Tillenius bjoti777 at student.liu.se
Tue Jun 1 08:10:04 EDT 2004


On Tue, Jun 01, 2004 at 09:53:01AM +0200, Philipp von Weitershausen wrote:
> 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.

The url will be quoted utf-8, acccording to the standards. If you want it
in some other encoding, you could always unquote it and encode it.
Although, IMHO it's a bad idea displaying the url in a specific
encoding. Zope3 expects the URL to be quoted utf-8, if you give Zope3 a
KR-8 encoded url, it won't work. I don't think we should encourage this
kind of behaviour.

> >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.

I'm almost fine with this, __str__ should still return ascii, it should
quote the url instead (but maybe that's what you meant).

Regards,
  Bjorn



More information about the Zope3-dev mailing list