views:

321

answers:

1

I'm looking for the simplest way of using python and SQLAlchemy to produce some XML for a jQuery based HTTP client. Right now I'm using mod_python's CGI handler but I'm unhappy with the fact that I can't persist stuff like the SQLAlchemy session.

The mod_python publisher handler that is apparently capable of persisting stuff does not allow requests with XML content type (as used by jQuery's ajax stuff) so I can't use it.

What other options are there?

+2  A: 

You could always write your own handler, which is the way mod_python is normally intended to be used. You would have to set some HTTP headers (and you could have a look at the publisher handler's source code for inspiration on that), but otherwise I don't think it's much more complicated than what you've been trying to do.

Though as long as you're at it, I would suggest trying mod_wsgi instead of mod_python, which is probably eventually going to supersede mod_python. WSGI is a Python standard for writing web applications.

David Zaslavsky
Thanks for the info, I think I'll try mod_wsgi, it looks like mod_python is getting phased out (last update is on web page is dated Jan 2008).
diciu
Good luck with it ;-) It takes a bit of time to learn how WSGI works but I think it's worth it in the long run.
David Zaslavsky
+1: switch to mod_wsgi and use a wsgi-based framework.
S.Lott
My personal favorite WSGI framework is CherryPy. It is, in fact, the only "web framework" I like due to the fact that its almost entirely transparent. You're just writing Python programs...
Shaun