Edgewall Software

Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#276 closed defect (fixed)

Python code in template is not executed correctly

Reported by: anonymous Owned by: cmlenz
Priority: minor Milestone: 0.6
Component: Template processing Version: 0.5
Keywords: python, execution, template Cc:

Description

Expected behavior: Python code in Genshi sample template below defines function "hello()" which produces <b>hello, world</b> in rendered template Erroneous result: genshi.template.eval.UndefinedError?: "tag" not defined

(I tried to use the function more() to reproduce the functionality of hello(), but it doesn't work, either, since the HTML-tags will be escaped in the output. Is there a way to avoid this?)

Sample template code:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" xmlns:xi="http://www.w3.org/2001/XInclude">
<head></head>
<body>
<?python
def hello():
    from genshi.builder import tag
    return tag.b('hello world')
def more():
    return '<strong>another greeting</strong>'
?>
<p>First one: ${hello()}</p>
<p>Second one: ${more()}</p>
</body>
</html>

Change History (3)

comment:1 Changed 16 years ago by cmlenz

  • Status changed from new to assigned

comment:2 Changed 16 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from assigned to closed

Should be fixed by [1008], and ported to 0.5.x in [1010].

comment:3 Changed 15 years ago by cmlenz

  • Milestone changed from 0.5.2 to 0.6

Milestone 0.5.2 deleted

Note: See TracTickets for help on using tickets.