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,
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,
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