[Zope3-dev] Re: Apache rewrite rules and URLs: an experiment

Jim Fulton jim at zope.com
Thu Nov 4 11:01:12 EST 2004


Bjorn Tillenius wrote:
> On Thu, Nov 04, 2004 at 09:48:56AM -0500, Jim Fulton wrote:
> 
>>Peter Mayne wrote:
>>
>>>If I try the above <tal:block> when I access Zope directly, it works. 
>>>However, if I access it via Apache, I get:
>>>
>>>...
>>> File "C:\opt\Python23\Lib\site-packages\zope\tal\talinterpreter.py", 
>>>line 451, in do_insertText_tal
>>>   text = self.engine.evaluateText(stuff[0])
>>> File 
>>>"C:\opt\Python23\Lib\site-packages\zope\app\pagetemplate\engine.py", 
>>>line 105, in evaluateText
>>>   return unicode(text)
>>> File 
>>>"C:\opt\Python23\Lib\site-packages\zope\app\traversing\browser\absoluteur
>>>l.py", line 101, in __unicode__
>>>   return urllib.unquote(self.__str__()).decode('utf-8')
>>>AttributeError: 'unicode' object has no attribute 'decode'
>>
>>That's odd.
>>
>>
>>>I'm not even going to think about why this is happening.
>>
>>Suit yourself.  Someone should think about why it's happening.
> 
> 
> I would guess that some variable that apache sets to determine the host
> is being represented as a unicode string.

But it gets to Zope via HTTP, which is an ASCII subset.  The publisher
is supposed to give all of this to Zope decoded.  IOW, the input data
to getApplicationURL should always be unicode.  I guess getApplicationURL
encodes. (? I don't remember the details.)

Hm, the interface for getApplicationURL doesn't say whether the returned
value is encoded. It needs to say this.  The interface needs to be fixed
IOW.

Given:

- We expect a URL

- URLs must be URL encoded

- *Before* URL encoding, we need to utf-8 encode

Then the output of getApplicationURL must certainly be a utf-8-url-encoded
string.

 > Due to this
> request.getApplicationURL() returns a unicode string as well, instead of
> an ascii string, which it normally does.
> 
> I can take a closer look at it later when I get some spare time, if
> nobody else wants to do it.

That would be great!

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Zope3-dev mailing list