David Fraser
davidf at sjsoft.com
Wed Aug 18 12:51:22 EDT 2004
Amir Salihefendic wrote: > I was pretty tired of the way that you test out stuff in mod_python. > I.e. you use req.write(variable), req.write(dir(object)) etc. Yes it can be tiring, looks interesting. Thought I would throw in some methods I use for debugging: Use the command line: Run Apache server from command line with -DONE_PROCESS and just print to stdout - appears on screen. This can be easier than adding stuff into the page using req.write, particularly if you don't have the request object at the right point in the program. Reloader system: I have a python script that lets me run Apache from the command line and restart it manually. It's a bit brutal (it kills the process and launches another one) but it makes for quick debugging. I find this means I can keep the given web page open, change the code quickly, restart Apache without having to worry about modules being reloaded etc. It's actually much quicker debugging web apps like this than standard apps, as you can keep all the state in the web browser and restart the server seamlessly underneath. Of course, you don't want to do this on your production servers :-) Logging input and output: For debugging hard-to-understand problems on our client sites, I wrote a system that lets you configure client requests and response pages to be logged to a file. This has been invaluable when we can't get into the client machines and can't understand why it is doing something - they simple turn on recording and email us the resulting file. David
|