[Zope3-dev] Re: Make AbsoluteURL produce quoted urls
Bjorn Tillenius
bjoti777 at student.liu.se
Tue Jun 1 12:37:27 EDT 2004
On Tue, Jun 01, 2004 at 02:39:24PM +0200, Philipp von Weitershausen wrote:
> Bjorn Tillenius wrote:
> >> 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).
>
> Indeed the spec (http://www.ietf.org/rfc/rfc2718.txt, section 2.2.5)
> suggests::
>
> Unless there is some compelling reason for a
> particular scheme to do otherwise, translating character sequences
> into UTF-8 (RFC 2279) [3] and then subsequently using the %HH
> encoding for unsafe octets is recommended.
>
> So, __str__ could indeed first encode to UTF-8 and then urlquote so we
> end up with%HH. I can't come up with a good use case for wanting a
> string but not quoted, so having either unicode or a quoted string would
> be enough and easily implemented.
I tested some, and it seems that TALES use __call__ in favour of
__str__. Therefore I want to do the following:
* Add __unicode__, which will of course return a unicode string.
* Change __str__ so that it takes the unicode url, encodes it to
utf-8, and urlquotes it before it gets returned.
No change will be done to __call__'s behaviour since I think it should
be easier to conform to the standards than to break them.
Is this OK with everyone?
Regards,
Bjorn
More information about the Zope3-dev
mailing list