[Zope-CMF] Decode for Record objects

Charlie Clark charlie at begeistert.org
Thu Jan 10 06:45:20 EST 2008


Am 10.01.2008 um 11:54 schrieb Jens Vagelpohl:

> It may be helpful if you describe what you were trying to do and  
> what failure you're seeing so everyone has a little context for  
> this request, which AFAIK has never come up anywhere.


:oops: Sorry, I thought this was a known issue.

If I have non-ASCII data in an RDBMS that I wish to use in a CMF site  
or even straight ZPT's you get a UnicodeError when accessing the non- 
ASCII Values which you get around using the decode utility.

ie.

<tal:repeat repeat="result context/someSQLQuery"> <- or from **options
    <p tal:content="string:${result/name}"></p>
</tal:repeat>

This will raise
Error Type: UnicodeDecodeError
Error Value: 'ascii' codec can't decode byte 0xc3 in position 1:  
ordinal not in range(128)

For something coming from a UTF-8 database to a UTF-8 site with  
zpublisher-default-encoding set to UTF-8

NB. content="result/name" doesn't raise the error

Actually this might not be anything to do with the CMF but simply the  
ZPT bug
that I have discussed a bit with Andreas but lost the bug id. Which  
I've now found again: https://bugs.launchpad.net/zope2/+bug/143932

However, I think the error is raised because utils.decode simply  
returns any values untouched it doesn't know what to do with which is  
why I think it might be worth extending. OTOH it might something that  
is better fixed in the Shared.RDBMS.Results module

Clearer or muddier now?

Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226





More information about the Zope-CMF mailing list