This is standard Python Debugger extended with a few features that makes debugging easier.
stxnext.pdb is targeted mainly at zope users, but can be used for other python projects too.
New features added to standard pdb:
improved dir function. Standard dir function lists names of all methods and attributes of some object. Improved dir prints output from this function in few columns. Also possible is filtering using regular expressions.
(STX Next pdb) obj = object()
(STX Next pdb) dir(obj)
(STX Next pdb) dir obj attr
(STX Next pdb) dir obj ^__[r-z]+
info command prints basic information about object.
(STX Next pdb) info obj
type: <type 'object'>
class: <type 'object'>
str: <object object at 0x7fbf7b7835d0>
repr: <object object at 0x7fbf7b7835d0>
docstring: The most base type
update_locals (ul) - update current locals by adding a few useful variables and functions. If stxnext.pdb find zope or plone it will import frequently used functions (e.g. getToolByName, getMultiAdapter, alsoProvides). If context is available plone tools will also be imported. stxnext.pdb looks for variables named self.context, context and self in current locals. In case of other context it could be passed as a parameter:
(STX Next pdb) update_locals #zope found, context unknown
(STX Next pdb) ul this_is_context #zope and plone found, correct context
stxnext.pdb can be opened by standard pdb invoke - except pdb should be imported from stxnext module:
>>> import pdb;pdb.set_trace() #open standard pdb
>>> from stxnext import pdb;pdb.set_trace() #
(STX Next pdb) c
If you run zope instance with debug-mode=on pdb can be invoked from web browser - just add pdb to url (e.g. http://127.0.0.1:8080/plonesite/pdb). In this approach stxnext.pdb tries to turn on tab completion - see rlcompleter documentation.
Alternatively, if you are using zc.buildout to manage your project, you can do this:
Add stxnext.pdb to the list of eggs to install, e.g.:
If you're using plone.recipe.zope2instance recipe to manage your instance add this lines to install a ZCML slug:
recipe = plone.recipe.zope2instance
If you're using zc.zope3recipes:application recipe to manage your instance add this lines to install a ZCML slug:
recipe = zc.zope3recipes:application
<include package="stxnext.pdb" />
Re-run buildout, e.g. with:
You can skip the ZCML slug if you are going to explicitly include the package from another package's configure.zcml file.