I'm just getting started with pylons, and am trying to figure out how to view the contents of variables for debugging without rendering the template.
For example:
class IndexController(BaseController):
def index(self):
# Return a rendered template
#return render('/index.mako')
# or, return a response
return render('/index.mako' )
def test(self):
v = request.params
return v
I would like to view the contents of array v, but I can't fig开发者_Go百科ure out how to do it !!
Thanks.
You can use cgitb to debug web applications, it can output detailed tracebacks to files, including variables contents. Here is an article detailing how to use it.
If you can see the server stdout you can also simply print
the variable, or else write it to a file: open("my-debug-log.txt", "w").write(repr(variable))
. pprint can help making complex data structures (nested arrays, complex dicts, etc...) easier to read in this case.
精彩评论