简体   繁体   English

从mod_python转换为mod_wsgi

[英]Converting from mod_python to mod_wsgi

My website is written in Python and currently runs under mod_python with Apache. 我的网站是用Python编写的,目前在Apache的mod_python下运行。 Lately I've had to put in a few ugly hacks that make me think it might be worth converting the site to mod_wsgi. 最近我不得不加入一些让我认为可能值得将网站转换为mod_wsgi的丑陋黑客。 But I've gotten used to using some of mod_python's utility classes, especially FieldStorage and Session (and sometimes Cookie ), and from a scan of PEP 333 , I don't see any equivalents to these. 但是我已经习惯了使用一些mod_python的实用程序类,特别是FieldStorageSession (有时候是Cookie ),而且从PEP 333的扫描中,我看不到它们的任何等价物。 (Not surprising, because I understand that those kinds of utilities don't belong in the WSGI spec) (这并不奇怪,因为我了解这些实用程序不属于WSGI规范)

Question is, are there "standard" (ie commonly accepted) replacements for these mod_python utility classes that I can use in WSGI, or could I/should I write my own? 问题是,我可以在WSGI中使用这些mod_python实用程序类的“标准”(即通常接受的)替换,还是我/我应该自己编写?

(FYI: currently using Python 2.5) (仅供参考:目前正在使用Python 2.5)

Look at Werkzeug . 看看Werkzeug You may have to do some rewriting. 你可能不得不做一些重写。 You will probably be pleased with the results of imposing the WSGI world-view on your application. 您可能会对在您的应用程序中强加WSGI世界视图的结果感到满意。

You can use FieldStorage in 'cgi' module and the 'Cookie' module. 您可以在'cgi'模块和'Cookie'模块中使用FieldStorage。 There is no equivalent to Session in Python standard libraries. 没有与Python标准库中的Session等效的东西。 For WSGI applications you can use Beaker for sessions. 对于WSGI应用程序,您可以使用Beaker进行会话。

请看一下whiff - 它提供内置功能,用于操作现场数据和会话等基于wsgi的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM