Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Version 1 (modified by jorge.vargas, 13 years ago) (diff)


This is a clever idea I had that maybe someone else could find usefull

I'll like to thank David Stanek from the Kid discuss list that help me out, when my call to locals() recurse to infinity

So I wanted a kid template that will display any variable that I send to it, so later on a designer or myself will replace it with the real template.

so here it is.

def template_locals(template):
   for name, value in template.__dict__.iteritems():
        if not name.startswith('_') and not name.startswith('tg') and not name is "std":
            yield name, repr(value)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns=""
        <title>Welcome to TurboGears</title>
        <li py:for="var,val in template_locals(self)">
           <span>${var} = ${val}</span>

please note that the template_locals function maybe filter out whatever you like all that needs to be done is add more lines to that if.