开发者

How can I view the contents of an array within controller directly for debugging?

开发者 https://www.devze.com 2022-12-18 17:39 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号