开发者

Django decorator, adding method to WSGIRequest

Using a decorator I was trying to add a method to WSGIRequest request, just like is_ajax(). Since I could not find a proper way I just updated request.META with the info needed开发者_如何学Python.

Should I look into adding method at runtime in Python ?


You can try to write custom middleware and add this method to request during request process.

See this for more info how to write middleware:

http://docs.djangoproject.com/en/dev/topics/http/middleware/#writing-your-own-middleware

http://www.djangobook.com/en/beta/chapter16/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜