2

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?

diciu
  • 29,133
  • 4
  • 51
  • 68

1 Answers1

2

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 Z
  • 128,184
  • 27
  • 255
  • 279
  • 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 Aug 13 '09 at 15:29
  • 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 Z Aug 13 '09 at 17:35
  • 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 Aug 14 '09 at 13:02