|
折腾了好几天,终于搞定,特此记录,如有大牛发现方法有所不妥,请指正一下,不胜感激涕零........
过程如下:
假设python2.5和quixote你已经安装了
1.安装apache2.2 ,过程略
2.下载mod_wsgi.so
3.copy到apache的modlues目录下
4.给quixote准备连接mod_wsgi的脚本,代码如下:
由于qwip需要支持多线程的publisher,所以需要继承publisher实现多线程支持,实现的例子在quixote的demo文件夹中有,代码:
multi thread support
1
#multi thread support
2import thread
3class ThreadedPublisher (Publisher):
4 is_thread_safe = True
5 def __init__ (self, root_namespace, config=None):
6 Publisher.__init__(self, root_namespace, config)
7 self._request_dict = {}
8 def _set_request(self, request):
9 self._request_dict[thread.get_ident()] = request
10 def _clear_request(self):
11 try:
12 del self._request_dict[thread.get_ident()]
13 except KeyError:
14 pass
15 def get_request(self):
16 return self._request_dict.get(thread.get_ident())
注意 is_thread_safe = True 这一行是例子中没有的,但是必须加,不然qwip会认为你的publisher不是线程安全的,哪怕你已经做了多线程的处理。
有了这个类之后就简单了,只需要:
Create application
1def create_publisher():
2 #return Publisher(RootDirectory(),
3 # display_exceptions='plain')
4 return ThreadedPublisher(RootDirectory())
5
6import traceback
7from quixote import get_wsgi_app
8
9try:
10 pub = create_publisher()
11 application = get_wsgi_app()
12except TypeError,e:
13 pass
注意application = get_wsgi_app()这个对象名称必须是application,不然mod_wsgi找不到能调用的东西。
5.有了连接的脚本后就只需要配置mod_wsgi就行了
1WSGIScriptAlias /test D:/WorkPlace/alex/TestQuixote/wsgi.py
2
3 WSGIApplicationGroup %{GLOBAL}
4 Order deny,allow
5 Allow from all
6
我这里配置了一个目录,其余的可以举一反三 |
|
|