mod_python 的 CGI 处理程序的替代品

发布于 2024-07-30 12:20:47 字数 249 浏览 9 评论 0原文

我正在寻找使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云雾 2024-08-06 12:20:47

您始终可以编写自己的处理程序,这就是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文