[Zope] Using tal:attributes in XML with non-ASCII characters
Andrew Veitch
andrew at logicalware.com
Sun Mar 19 20:53:56 EST 2006
On 19 Mar 2006, at 19:11, Dieter Maurer wrote:
> This means that almost surely your "non-ascii" was not encoded
> in UTF-8. Encode them this way and it will work.
Here's a test template that I created through the ZMI:
<?xml version="1.0" encoding="utf-8"?>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
tal:define="dummy python:request.RESPONSE.setHeader('content-
type', 'text/html;;charset=UTF-8')">
<body>
<form>
<input name="blah" type="text" tal:attributes="value python:chr
(200).encode('utf-8')" />
</form>
</body>
</html>
This gives:
Error Type: UnicodeDecodeError
Error Value: 'ascii' codec can't decode byte 0x80 in position 0:
ordinal not in range(128)
If I change the input line to:
<input name="blah" type="text" tal:attributes="value python:chr(200)" />
Then this will work in HTML mode but will fail in XML mode.
>> Finally, I tried tal:attributes with my function and the structure
>> keyword but 'structure' isn't supported with tal:attributes.
>
> I have extended our local Zope to support "structure" for
> attributes as well.
I had a look in TAL, and at the bottom of TALDefs.py is a function
called attrEscape(s) which correctly escapes attributes but
unfortunately this function doesn't seem to be used.
> I could provide patches, if useful.
I would be very interested to see you patches.
Thanks in advance
Andrew
--
Logicalware Ltd
Stuart House, Eskmills, Musselburgh, EH21 7PQ, UK
Tel: +44(0)131 273 5130 http://www.logicalware.com
More information about the Zope
mailing list