[Grok-dev] Graphical debugging of Grok with Komodo IDE

Sebastian Ware sebastian at urbantalk.se
Tue Sep 4 10:18:53 EDT 2007


Just a little update fixing an annoying detail... (inline)

Mvh Sebastian

31 aug 2007 kl. 14.32 skrev Sebastian Ware:

> 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/bin/ 
> zopectl fg');
>               }, 200, ko, window);

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.

>
>    // 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.
>
> 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
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev



More information about the Grok-dev mailing list