[Grok-dev] various balls grok has in the air (and help us catch
them)
Sebastian Ware
sebastian at urbantalk.se
Mon Sep 10 17:41:39 EDT 2007
Reposting with edit...
Hi!
I just want to post a howto on how to setup the Komodo IDE graphical
debugger for your Grok project.
1 Set the PYTHONPATH
a) either in the terminal before you execute the "bin/zopectl fg"
command
http://community.activestate.com/forum-topic/debugging-zope-apps
b) or (if you start Zope from Komodo) by adding PYTHONPATH with a
path to the
Komodo debugger library. Go to "Preferences / Environment /
New..." and
add Name= PYTHONPATH, Value= /path/to/debugger_library
The Komodo Python debugger library is called "dbgp". In Macosx
you can find it
the Komodo IDE.app package under Contents/SharedSupport/. I
actually copied it
to another location but I don't think that is necessary.
2 Make sure that the Komodo debugger listens to the right port
Go to "Preferences / Debugger / Connection" and choose "a
specific port". I selected
port 9000 (but I think anything above 1024 should be ok in Macosx).
3 Add the following two lines anywhere in a .py file in your project
(outside any class or method definition)
import dbgp.client
dbgp.client.brk(host="localhost", port=9000)
Note that it supports remote debugging, but that requires you
opening the firewall on the
computer running the debugger.
4 Start Zope from within Komodo IDE
I use the following macro (search for "macro" in Komodo help to
learn how to
create a macro) and have a keybinding to "shift-command r":
// Macro recorded on Tue Jun 19 2007 21:08:09 GMT+0200 (CEST)
komodo.assertMacroVersion(2);
ko.run.output.kill(-1);
if (komodo.view) { komodo.view.setFocus() };
setTimeout(function(ko, win) {
ko.run.runEncodedCommand(win, '/your/path/to/runzope
and some params');
}, 200, ko, window);
// Note "200" is the delay before starting the server, allowing
the output.kill command to
// execute properly. You might want to extend this on a slower
computer.
** HOW TO FIGURE OUT THE PATH AND PARAMETERS FOR RUNZOPE **
To run zope, use the runzope command, otherwise, when you kill the
process in order to restart, it won't kill the server process, only
the zopectl process. In a terminal window (unix), if you have started
your Grok app with the zopectl command, you can use...
ps -aux | grep python
...to find the path and parameters to sen to runzope.
** HOW TO FIGURE OUT THE PATH AND PARAMETERS FOR RUNZOPE **
Zope will start and stop at the "clien.brk" command added in step 3.
You can add and remove your break points and press the "Go / continue
debugging" button in the toolbar. The Komodo debugger supports
regular, conditional, variable based, function call, function return
and exception base breakpoints. (At the time of writing I have only
set regular line based breakpoints.)
Once the Komodo debugger breaks at a break point you can:
-step into/over/return from statements
-inspect local/global/watch variables
-check the call stack
-enter interactive mode to perform arbitrary python code (this gives
you a Python prompt, not the pdb prompt)
Mvh Sebastian
10 sep 2007 kl. 22.51 skrev Martijn Faassen:
> * graphical debugging of Grok with Komodo - by Sebastian. Let's get
> this
> on the website, please.
More information about the Grok-dev
mailing list