Unable to use Templates

39 views
Skip to first unread message

Jarno Elovirta

unread,
Sep 21, 2008, 2:51:57 PM9/21/08
to Genshi
Just installed Genshi 0.5.1 on OS X 10.5 from source tarball. When I
try to use Templates, I get a AttributeError.

HINFLMAC030-2:Temp jelovirt$ python -V
Python 2.5.1
HINFLMAC030-2:Temp jelovirt$ cat test.py
from genshi import XML
from genshi.template import MarkupTemplate

stream = XML('<h1>Hello, World!</h1>')
print stream.render()

stream = MarkupTemplate('<h1>Hello, $name!</
h1>').generate(name='world')
print stream.render()
HINFLMAC030-2:Temp jelovirt$ python test.py
'<h1>Hello, World!</h1>
Traceback (most recent call last):
File "test.py", line 7, in <module>
stream = MarkupTemplate('<h1>Hello, $name!</
h1>').generate(name='world')
File "build/bdist.macosx-10.5-i386/egg/genshi/template/base.py",
line 377, in __init__
File "build/bdist.macosx-10.5-i386/egg/genshi/template/markup.py",
line 211, in _parse
File "build/bdist.macosx-10.5-i386/egg/genshi/template/
interpolation.py", line 77, in interpolate
File "build/bdist.macosx-10.5-i386/egg/genshi/template/eval.py",
line 81, in __init__
File "build/bdist.macosx-10.5-i386/egg/genshi/template/eval.py",
line 421, in _parse
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/compiler/transformer.py", line 54, in parse
return Transformer().parseexpr(buf)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/compiler/transformer.py", line 133, in parseexpr
return self.transform(parser.expr(text))
AttributeError: 'module' object has no attribute 'expr'

Or, when I try to load a Template from a separate file, I get

Traceback (most recent call last):
File "test2.py", line 16, in <module>
tmpl = loader.load('form.template.html')
File "build/bdist.macosx-10.5-i386/egg/genshi/template/loader.py",
line 227, in load
File "build/bdist.macosx-10.5-i386/egg/genshi/template/loader.py",
line 265, in _instantiate
File "build/bdist.macosx-10.5-i386/egg/genshi/template/base.py",
line 377, in __init__
File "build/bdist.macosx-10.5-i386/egg/genshi/template/markup.py",
line 202, in _parse
File "build/bdist.macosx-10.5-i386/egg/genshi/template/eval.py",
line 81, in __init__
File "build/bdist.macosx-10.5-i386/egg/genshi/template/eval.py",
line 421, in _parse
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/compiler/transformer.py", line 52, in parse
return Transformer().parsesuite(buf)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/compiler/transformer.py", line 129, in parsesuite
return self.transform(parser.suite(text))
AttributeError: 'module' object has no attribute 'suite'

Any clues what I'm missing?

Cheers,

Jarno

Matt Good

unread,
Sep 22, 2008, 3:50:33 PM9/22/08
to Genshi
It looks like you have another parser.py somewhere on your
PYTHONPATH. You'll have to rename that so that it doesn't conflict
with Python's own module with the same name.

-- Matt
Reply all
Reply to author
Forward
0 new messages