ここにアイデアがあります(具体化する必要があり、おそらくうまくいかないでしょう):
これが私が始めるものです:
from mod_python import apache
from wsgiref.handlers import BaseHandler
class MyWSGIHandler(BaseHandler):
def __init__(self, apachereq):
BaseHandler.__init__(self)
self.apachereq = apachereq
def _write(self, data):
self.apachereq.write(data)
# override the other required methods of BaseHandler, see
# http://docs.python.org/library/wsgiref.html#wsgiref.handlers.BaseHandler
wsgi_app = create_your_wsgi_app()
def handler(req):
wsgi_handler = MyWSGIHandler(req)
wsgi_handler.run(wsgi_app)
return apache.OK
アイデア 2 (かなりハック):
ハンドラー コードでwerkzeug wsgi テスト モジュールを使用して、要求を WSGI アプリに渡し、werkzeug 応答を取得して、その応答を apache に書き込むこともできます。
何かのようなもの:
from mod_python import apache
from werkzeug.test import Client
from werkzeug.wrappers import BaseResponse
wsgi_app = create_your_wsgi_app()
def handler(req):
c = Client(wsgi_app, BaseResponse)
resp = c.get(somehow_get_the_url_from(req)) # or c.post if it's a POST request
req.write(resp.data) # ... and find a way to write the headers as well
return apache.OK