I have a framework built on top of Werkzeug, which is built on the wsgiref wsgi server. How would I go about debugging this in komodo? I have debugging of regular python scripts figured out, but whenever I use the framework my breakpoints never get reached.
Thanks.
You'll need to use Komodo's remote debugging features in order to properly debug a WSGI application. There is a good description of the required steps in the Django debugging article:
http://community.activestate.com/forum-topic/debugging-django-apps#comme...
Let us know if you have problems getting this working.
Cheers,
Todd
Todd,
Thanks for pointing that out. I was able to figure out what I needed from that post and from the TurboGears one:
http://community.activestate.com/forum-topic/debugging-turbogears
Basically, all I head to do was add this at the top of my main "runserver" script (AFTER I made sure dbgp was on my PYTHONPATH):
making sure the port was set to what Komodo showed in Debug->Listener Status
Caveats:
1) Multiple debug sessions get started if I am using a reloader. I decided to just skip reloading when debugging (this was noted in the documentation)
2) I get a *bunch* of erroneous output when doing this that says "SystemError('error return without exception..."
Any thoughts on how to get rid of that error output?
It is good that you've got the debugging figured out. For the error "SystemError('error return without exception...", could you log a bug for that at:
http://bugs.activestate.com/enter_bug.cgi?product=komodo
Please include how to reproduce this error and the full traceback exceptions, which you can find in Komodo's error log:
http://community.activestate.com/faq/komodo-file-locations#log_files
Thanks,
Todd
Here's a simple example of a wsgi application (in this case Trac) debuggable with dbgp. You'll need PyDBGP installed. Apache will need to be configured to use this script as the wsgi process script (e.g. WSGIScriptAlias points to this). See the google url in the code for more information. I have only tested this with Apache and mod_wsgi.
# -*- coding: utf-8 -*-
# This is a simple mod_wsgi script for Trac
# See also:
# http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac
# http://trac.edgewall.org/wiki/TracModWSGI
#
# http://code.google.com/p/modwsgi/wiki/DebuggingTechniques
# this should be run via httpd -x
import sys
sys.stdout = sys.stderr
from trac.web.main import dispatch_request
class Debugger:
def __init__(self, object):
self.__object = object
def __call__(self, *args, **kwargs):
environ = args[0]
# set dbgp defaults, these can be set in apache conf files
environ.setdefault('dbgp.enabled', '')
environ.setdefault('dbgp.idekey', '') # dbgp proxy support
environ.setdefault('dbgp.host', '127.0.0.1')
environ.setdefault('dbgp.port', 9000)
enabled = environ.get('dbgp.enabled')
if enabled:
import dbgp.client
idekey = environ.get('dbgp.idekey')
host = environ.get('dbgp.host')
port = environ.get('dbgp.port')
client = dbgp.client.backendCmd(idekey)
client.stdin_enabled = 0
client.connect(host, port, 'application', [__file__])
# despite it's name, this is how to run a function
return client.runThread(self.__object, args, kwargs)
else:
# debugging disabled, continue normally
return self.__object(*args, **kwargs)
application = Debugger(dispatch_request)
Thanks for informative post. I was nothing to known about how i can debug WSGI server based application on my laptop. Because it was creating so much errors. Know I have gotten your blog and feel satisfied that I can solve this problem now.
I am not so knowledgeable about this matter. So i have to learn it. Thanks for the post.
[url=http://pret-auto.org][color=#F4F4F4][u]pret auto[/u][/color][/url]