[PATCH 0/2] making raw text more raw
Doug Knight <[email protected]> Mon, 14 Dec 2009 16:36:07 -0900
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
The Cheetah user documentation says that text inside a #raw .. #end raw tag
pair will be printed verbaitm. Cheetah is performing substitutions in raw
text where it should not be doing so as can be seen in the this example:
Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57)
[GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> t = """#raw
... This escape should be preserved: \\$unexpanded
... So should this one: \\#blah
... The string "\\012" should not disappear. #end raw"""
>>> print t
#raw
This escape should be preserved: \$unexpanded
So should this one: \#blah
The string "\012" should not disappear. #end raw
>>> import Cheetah.Template
>>> print Cheetah.Template.Template ( t, [ { "unexpanded" : "EXPANDED" } ] )
This escape should be preserved: $unexpanded
So should this one: #blah
The string "" should not disappear.
>>>
I believe the epected results here should be:
[ ... ]
>>> import Cheetah.Template
>>> print Cheetah.Template.Template ( t, [ { "unexpanded" : "EXPANDED" } ] )
This escape should be preserved: \$unexpanded
So should this one: \#blah
The string "\012" should not disappear.
>>>
This is causing scripts that cobbler puts in #raw blocks to come out
mangled after Cheetah processes them. These substitutions are happening
because these escape sequences are being parsed in
Cheetah.Compiler.Compiler.commitStrConst, after the parser has submitted
the raw text via addRawText.
I would like to suggest the following patches, which move the code that
parses escaped variables and directives into the parser, calling it only
from eatPlainText, and corrects the bug in the handling of repr
generated line feeds.
Thanks,
Doug Knight
------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev