[Grok-dev] Re: Suggestions or advice for how to debug a grok app
using PyDev?
Martin Aspeli
optilude at gmx.net
Mon Jun 2 03:41:50 EDT 2008
Hi,
Craeg Strong wrote:
> After unsuccessfully trying both Eric4 and SPE, I finally settled on
> Eclipse + PyDev as a debugging environment/IDE for Grok.
>
> I created a PyDEV project and used pb.recipes.pydev to add eggs to the
> external PYTHONPATH
>
> Unfortunately, it only added some of the eggs in buildout-eggs, not all
> of them, so I ended up adding the rest by hand anyway.
I am using PyDev with Eclipse on Windows, and ended up using
collective.recipe.omelette to wire up a faux pythonpath with all
dependencies. I then set this as a source folder in pydev. I also set
the Zope 2 lib/python directory as one (you probably don't need anything
like this), and my custom source folders. This gives me full code
completion and proper inspection.
> It was relatively straightforward to get my project set up so I could
> run the debugger on a unit test in app_tests/
>
> However, I am stumped trying to actually debug a running zope3 instance
> in PyDev. I thought of several possible angles of attack:
>
> - create a gigantic "super project" containing all the buildout eggs
> plus my project and put everything in the project path, and debug
> directly from zope.app.twisted.main
I found this tricky on zope 2, at least, because at some point, Zope
forks and the debugger loses its handle on the code.
> - put all the buildout eggs in one external project and make my project
> depend on it
> - make a separate pydev project for each buildout egg
> - any one of the above, but rather than start zope within the debugger,
> just run it from an external script and attach the debugger to the
> running instance
I'd use the debug server. You need to add the pydevd sources to your
PYTHONPATH (I start Zope from within Eclipse, and have it as a source
folder) and then you do:
import pydevd; pydevd.set_trace()
You'll need to start the debug server in Eclipse (go to the debug
perspective, there's a toolbar button) and then restart Zope. Once that
line is hit, you should get to the debugger.
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the Grok-dev
mailing list