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

Bjorn Tillenius bjoti777 at student.liu.se
Tue Jun 1 17:48:05 EDT 2004


On Tue, Jun 01, 2004 at 09:40:54PM +0100, Stuart Bishop wrote:
> On 01/06/2004, at 5:33 PM, Bjorn Tillenius wrote:
> >So, I want to do the following changes::
> >
> >  * 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.
> 
> I think that is pretty much what I had. I don't know if that will
> work the way you want, in that I *think* that adding the __unicode__
> method means you will need to do the following:
> 	<a tal:attributes="href python:str(url)" tal:content="url" />
> (ie. TALES will prefer the Unicode representation over the plain text).

Could be that TALES prefers __unicode__ over __str__, but it will look
for __call__ first. So it'll work the way I want.

> I prefer it though, so I'm not worried if this actually is the case :-)

So, I take that as you're ok with my changes :-)?

> The __str__ method *will* need to convert the domain portion of the
> URL using the IDNA encoding though (domain.encode('idna')). Not doing
> this will generate invalid URL's. I've updated the examples
> at http://images.stuartbishop.net/idna.html if people want a
> demonstration they can click on. It is the responsibility of
> AbsoluteURL because nothing else requires the domain portion
> to be ASCII (Not that I have tested how Z3 copes when it is running
> with a Unicode domain name... but I believe all of the Python
> stuff now correctly handles Unicode strings as domain names).

Well, I can tell you this. Today Zope3 can't handle unicode domains. My
changes will not make Zope3 handle it worse than today. Since I don't
need this feature, and know too little about it, I won't care about it.
But feel free to propose how Zope3 should handle unicode domains and
implement it if you want to.

Regards,
  Bjorn



More information about the Zope3-dev mailing list