开发者

django and deliverance as middleware

are there any examples on how to use Deliverance as a middlew开发者_StackOverflow社区are [1] into Django?

Thanks, SimO

[1] http://packages.python.org/Deliverance/modules/middleware.html


Unfortunately it's not easy, because Deliverance's internals rely heavily on WSGI and WebOb, so there's no straightforward way to transform a Django Response.

Your best bet is transforming the response after it leaves Django entirely. One way to do that is http-proxying to Django with deliverance-proxy. Another is hooking up Deliverance as a WSGI middleware. For example, if you're running Django with mod_wsgi, something like this might work in your .wsgi file:

[...]
import django.core.handlers.wsgi                                                                                                                 
application = django.core.handlers.wsgi.WSGIHandler()                                                                                            

from deliverance.middleware import make_deliverance_middleware                                                                                   
application = make_deliverance_middleware(application,
         rule_uri="file:///var/deliverance.xml", 
         theme_uri="http://theme.mysite.com") 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜