I'm about to start a fair amount of work extending Trac to fit our business requirements. So far I've used pythonWin and now Netbeans 6.5 as the development environments - neither of these seem to provide any way of debugging the plugin I am working on.
I'm totally new to Python so probably have not set up the development environment how it could be congfigured to get it debugging.
Am I missing something obvious? It seems a bit archaic to have to resort to printing debug messages to the Trac log, which is how I'm debugging at the moment.
You can create a wrapper wsgi script and run it in a debugger. For example:
import os
import trac.web.main
os.environ['TRAC_ENV'] = '/path/to/your/trac/env'
application = trac.web.main.dispatch_request
from flup.server.fcgi import WSGIServer
server = WSGIServer(application, bindAddress=("127.0.0.1", 9000), )
server.run()
You would run this script in the debugger, and you can use lighttpd as a frontend for the web application with a trivial config like this one:
server.document-root = "/path/to/your/trac/env"
server.port = 1234
server.modules = ( "mod_fastcgi" )
server.pid-file = "/path/to/your/trac/env/httpd.pid"
server.errorlog = "/path/to/your/trac/env/error.log"
fastcgi.server = ( "/" =>
(( "host" => "127.0.0.1",
"port" => 9000,
"docroot" => "/",
"check-local" => "disable",
))
)
Just run the fcgi wsgi wrapper in the debugger, set the breakpoints in your plugin, and open the web page.