Graham Dumpleton
grahamd at dscpl.com.au
Wed Apr 6 20:49:02 EDT 2005
Jamieson Becker wrote .. > btw, Graham, what's the best way to handle error management with > mod_python? log it to a db? catch all exceptions and throw them in a > file? Is the best pythonic way to throw errors to throw exceptions, or > should you return an error code from your functions? Any good tips or > hints here? I've actually been using Jabber to throw errors and debug > info in real time at me while coding, but Jabber 1x screws up the order > of the messages. Jabber 2x works great but there's a noticeable delay > while the page is generated. Error management isn't something I have gone into really. So far I have only been using mod_python for simple static based web site construction and simple forms based utilities talking to some live applications using XML-RPC where I am the primary user. In the first instance, no errors to report, in the latter I am the only real user and so I have PythonDebug still On. It is interesting to see you using Jabber though. Do you have to create a seperate socket connection to Jabber each time or does the connection to it persist? Does the message delivery aspects of the Jabber Python client run in a separate thread or when you publish a log message does it block until it has been delivered to the Jabber server and that is why you get a delay? If you are interested in this ability to get real time information out of Apache, you might be interested in one of my other projects. This project gives some similar capabilties to Jabber, ie., request and reply messaging, plus presence and publish and subscribe features. This package though is targeted specifically at application development which needs to be spread across multiple processes and platforms. This is different to Jabber where its main purpose is user focused instant messaging and using it in applications has come along later. With my package I already have it working to the point where each Apache subprocess can connect into the messaging system and thus request handlers can initiate remote calls against a backend application. One can even have services running in the Apache processes themselves and services running within distinct Python interpreters within the same Apache process can even talk amongst themselves at the same time as Apache is handling HTTP requests. The underlying message delivery runs in a separate thread and all socket communications is event driven, so true blocking of the system doesn't occur. Anyway, getting back to what you are doing with logging, with this system any error which you want logged could be published by a service associated with that Python interpreter in the Apache process. Another service running in the backend application could be subscribed to all these published log messages and it could collect them and log them to a file or even show them in realtime via a GUI if desired. Probably not much different to what you are doing, but using a different system. For reference, the package I am talking about is OSE. Information can be found at: http://ose.sourceforge.net The documentation for the Python wrappers is at: http://ose.sourceforge.net/browse.php?group=python-manual&entry=manual.htm Documentation doesn't as such explain how to hook it into Apache though as ability to do that is only in beta version of 8.0 whereas documentation describes version 7.0. I can give further details and finally get around to incorporating an example into Vampire if there is interest. Graham
|