[albatross-users] Accessing the list of names in the context?

Gregory Bond gnb at itga.com.au
Tue Nov 12 10:12:14 EST 2002


I'm trying to work out a way of debugging what's in the context at various 
points.  I tried this:
<al-macro name="showcontext">
    The current local context is:
    <ul>
      <al-for iter="ctxiter" expr="__dict__.keys()">
	<li><al-value expr="ctxiter.value()"> = 
	    <al-value expr="__dict__[ctxiter.value()]">
	    </li>
      </al-for>
    </ul>
  </al-macro>

but this doesn't work:

[snip....]
<al-macro name="showcontext">
  File "templates/cncancel/header.html", line 45, in al-for
      <al-for iter="ctxiter" expr="__dict__.keys()">

Traceback (most recent call last):
[snip...]
  File "/usr/local/lib/python2.1/site-packages/albatross/context.py", line 320, in eval_expr
    return eval(expr, self.__globals, self.locals.__dict__)
  File "<albatross>", line 0, in ?
NameError: name '__dict__' is not defined

which makes sense, given the code in the traceback!  I can obviously get around
this by adding a line like "ctx.locals.dict = cts.locals.__dict__" everythwere,
byt that means debugging involves changes to both the template and the .py
file.  Any way of doing this that doesn't involve editing the .py file?

Is it worth having the context do this assignment anyway?





More information about the Albatross-users mailing list