如何将 WSGI 实现中的 HTTP 数据输入到 Django 中?
我想创建一个 Django 应用程序,充当两个透明 WSGI 实现之间的中间件,仅传递数据。到目前为止,我希望这个应用程序做的就是将它接收到的 HTTP 数据记录到数据库中以进行调试,然后将信息传递到下一个 WSGI 实现(然后将这些信息处理到 Apache 等 Web 服务器
)问题是,如何编写一个仅接收现有 HTTP 数据而不是创建它的 Django 应用程序?我猜这个应用程序没有 url,只有某种视图、自定义 Django 中间件组件和数据库。 那么我如何将 WSGI 实现连接到 Django 应用程序的输入,以便 Django 可以读取信息、记录它,然后输出它?我知道如何进行实际的日志记录和输出,因为我只是对输入感到困惑。
I want to create a Django application that acts as middleware between two transparent WSGI implementations which simply pass along data. So far, all I want this application to do is log the HTTP data that it receives into a database for debugging purposes and then passes the information to the next WSGI implementation in line (which then handels this information to a web server like Apache)
My question is, how do I write a Django application that only receives existing HTTP data instead of creating it? I'm guessing this application would have no urls, just a view of some sort, a custom Django middleware component, and the database.
So how would I connect a WSGI implementation to the input of a Django app so that Django can read the information, log it, then output it? I know how to do the actual logging and outputting for I'm just confused about the inputting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
过去有一个 GSOC 项目与使 WSGI 中间件更容易/可能地插入 Django 相关。代码位于:
https://code.djangoproject.com/browser/ django/branches/soc2009/http-wsgi-improvements
我不知道发生了什么。
Alex Gaynor 还尝试了更好的 WSGI 集成:
http://alexgaynor.net/2010/jan/11/hot-django-wsgi-action-announcing-django-wsgi/
如果您在这里没有得到答案,建议询问在 Django 用户邮件列表上。
There was a GSOC project in the past related to making it easier/possible to plug WSGI middleware into Django. Code at:
https://code.djangoproject.com/browser/django/branches/soc2009/http-wsgi-improvements
I don't know what happened to that.
Alex Gaynor has also played with better WSGI integration:
http://alexgaynor.net/2010/jan/11/hot-django-wsgi-action-announcing-django-wsgi/
If you don't get an answer here then suggest asking on Django users mailing list.