Re: encoding problem

[email protected] Tue, 24 Nov 2009 19:03:44 -0800
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
On Tue, 24 Nov 2009, Juan Fiol wrote:

> Hi, using versions 2.2.2 and 2.4.0 in gentoo I found that previous working templates (with version 2.0.1) do not longer work. The error point out to encoding (ascii not being good for some chars). After posting to tahchee mail list, I included encoding directives like suggested in the manual:
> 
> #encoding: UTF-8

Are you referring to the *compiled* templates or the uncompiled templates? If
it's the former than I might need to bump the latest compatible version tuple.
If it's the latter, are you using encoded strings? If I remember correctly
there should be safe-guards in place to try to perform a best effort decoding
of strings (as per usual, a traceback would be helpful here with relevant
data).

> but they were not recognized. It finally seems that I could identify the problem to the file Compiler.py. The line looking for the encoding is using re.match rather than re.search
> I would think that re.match should work but in fact it does not. 
> 
> I corrected the problem in my system by applying the simple patch that is included at the end. Is it correct? Or the problem shows from some other issue that I am not seeing?

Looks simple enough, do you have a test case that I can add to our
regression tests?

> Another question: The behavior of cheetah has changed from version 2.0.1 . Previously I did not have any encoding defined and it just worked. Now I have to include a line with the encoding in each file to make it work. Is there another way to do it (like defining a global encoding)?
> 

I'll have to get back to you on the global encoding thing, the basis of this
change was to resolve a number of outstanding unicode issues with previous
versions of Cheetah, by making all internal strings to Cheetah unicode objects,
instead of a mix of encoded strings and unicode objects, etc.

Cheers,
-R. Tyler Ballance
--------------------------------------
 Jabber: [email protected]
 GitHub: http://github.com/rtyler
Twitter: http://twitter.com/agentdero
   Blog: http://unethicalblogger.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.13 (GNU/Linux)

iEYEARECAAYFAksMno8ACgkQFCbH3D9R4W/FbQCdFXBk4VgHAS9yU76zVLtK/D+K
PwgAnRwZqWsjJx2mp9dxW5Miwk9qibJX
=YIFd
-----END PGP SIGNATURE-----