Edgewall Software

Opened 17 years ago

Closed 17 years ago

#154 closed defect (duplicate)

Code Embed Example fails with "UndefinedError: "greeting" not defined"

Reported by: ilias@… Owned by: cmlenz
Priority: major Milestone:
Component: Template processing Version: 0.4.4
Keywords: Cc:

Description

I use this code within a template (as suggested in the documentation), but got an error "UndefinedError: "greeting" not defined".

Python 2.5, Trac 0.11dev-r5897), genshi 0.4.4

<div>
  <?python
      from genshi.builder import tag
      def greeting(name):
          return tag.b('Hello, %s!' % name) ?>
  ${greeting('world')}
</div>

Change History (4)

comment:1 Changed 17 years ago by ilias@…

I've just updated to "Genshi: 0.4.5dev-r730" (fetched from stable 0.4.x), still the same problem.

comment:2 Changed 17 years ago by cmlenz

I cannot reproduce this with either trunk or the stable branch.

Can you post a minimal but complete example that I can run (i.e. a Python file)?

comment:3 Changed 17 years ago by ilias@…

I don't know how to create an example.

But I've isolated the problem further (basicly the problem is solved for me, but something seems to be wrong with genshi or trac).

reproduction:

place the codeblock within the layout.html template of trac, right after the body tag:within the body tag.

<body py:match="body">
<div>
  <?python
      from genshi.builder import tag
      def greeting(name):
          return tag.b('Hello, %s!' % name) ?>
  ${greeting('world')}
</div>

If you place the code before the body tag, everything runs fine

<div>
  <?python
      from genshi.builder import tag
      def greeting(name):
          return tag.b('Hello, %s!' % name) ?>
  ${greeting('world')}
</div>

<body py:match="body">

comment:4 Changed 17 years ago by cmlenz

  • Component changed from General to Template processing
  • Milestone 0.5 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

#155 describes the same issue. As it has a test case and a patch, I'm closing this one as duplicate.

Note: See TracTickets for help on using tickets.