6

I don't have an easy access to the code, I'm working only with a Mako template, and I would like to know all the values that were made available to the template, which I can use.

Is there a way to add something in the template, so that the output result would contain all the variables (recursively)?

Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
Jānis Elmeris
  • 1,975
  • 1
  • 25
  • 43

2 Answers2

11

You're looking for the context object. After a minute or two of play:

${context.keys()}    # list of direct variable names
${context.__dict__}  # probably more along what you're looking for.

The entire section on the Mako Runtime environment is probably worth reading, especially the part 'All the built in names.' You may find the other post I just made relevant:

Mako how to check if variable exists or not.

Community
  • 1
  • 1
chris
  • 2,404
  • 3
  • 27
  • 33
0

Lets try this I think this must help:

${globals()}
Denis
  • 7,127
  • 8
  • 37
  • 58
  • Thanks for a suggestions. But it doesn't output what I need. For example, I certainly have a variable "objects" in my template (which I can loop through), but in the text that "globals()" output, the only instance of "objects" is this one: "'__doc__': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices."" :) – Jānis Elmeris May 22 '12 at 10:02
  • so and what type of variable objects ? – Denis May 22 '12 at 13:38
  • Not variable objects, a variable named "objects". :) I can read a value objects.name, for example. I would like to have a list where I can see that I can add, for example, among other values "objects.name"'s value into my template, or at least that "objects" is accessible. – Jānis Elmeris May 22 '12 at 14:03
  • I'm using OpenERP. Don't know what framework they use. I'm just a mere template designer. :) – Jānis Elmeris May 23 '12 at 10:48