PylonsHQ.

Layout: Fixed-width

Pylons debugger for people in a hurry

Skip to end of metadata
Go to start of metadata

Pylons debugger for people in a hurry

This is one of a set of quick guides for getting started with the different components of Pylons.

Introduction

When we have an error in our Pylons code we get the Error Traceback on a Pylons page.

if the problem is not immediately obvious from the debugging text and inspection of the code then you may want to try the following.

Setting a breakpoint

If the code is your own, just before the line of code that caused the error add the following line,

raise RuntimeError()

This stops the program just before the error and allows us to inspect the state (variable values etc.) using the interactive Python shell built into the webpage.

Click on the cross on the traceback to reveal a text box. You can now enter Python code to find out the program state, for instance,

>>> dir(mr_jones)
 ['name', 'address' etc.. ]
>>> dir(mr_jones.name)
 None

If our code had been expecting mr_jones.name to be assigned to something other than None then this would have raised an error. dir is also useful for determining what names are in the current namespace,

>>> dir()
 ['__builtins__', '__doc__' etc.. ]

type(), which returns an object's type, is also useful for determining errors in code.

Further reading

  • IBM developer works has an article on Python introspection detailing more python builtins you can use to diagnose problems

Labels

debugger debugger Delete
tutorial tutorial Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Powered by Pylons - Contact Administrators