mod_python 的 CGI 处理程序的替代品
我正在寻找使用 python 和 SQLAlchemy 为基于 jQuery 的 HTTP 客户端生成一些 XML 的最简单方法。 现在我正在使用 mod_python 的 CGI 处理程序,但我对无法保留 SQLAlchemy 会话之类的内容感到不满意。
mod_python 发布者处理程序显然能够持久保存内容,但不允许使用 XML 内容类型的请求(如 jQuery 的 ajax 内容所使用的),因此我无法使用它。
还有哪些其他选择?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您始终可以编写自己的处理程序,这就是 mod_python 通常的使用方式。 您必须设置一些 HTTP 标头(并且您可以查看发布者处理程序的源代码以获得灵感),但除此之外,我认为这并不比您一直在尝试做的事情复杂得多。
不过,只要您愿意,我建议您尝试使用 mod_wsgi 而不是 mod_python,后者可能最终会取代 mod_python。 WSGI 是用于编写 Web 应用程序的 Python 标准。
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.