如何将龙卷风HTTPRequest转换为Django HttpRequest或WSGIRequest?

时间:2022-04-10 01:08:28

I'm writing a socket.io app using Django and TornadIO2/Tornado. In the TonradIO2 Session, I have access to Tornado's HTTPRequest objects. However, I have no access to a django request object in my event handlers in the SocketConnection class. Ideally, I'd like all the configured django middlewhere to execute on the request object before reaching my event handlers. I could call them the middlewhere explicitly, but I need to convert the HTTPRequest object to a Django HttpRequest or a Django WSGIRequest object first. Any suggestions on how to achieve this?

我正在使用Django和TornadIO2 / Tornado编写socket.io应用程序。在TonradIO2 Session中,我可以访问Tornado的HTTPRequest对象。但是,我无法访问SocketConnection类中的事件处理程序中的django请求对象。理想情况下,我希望所有已配置的django midwhere在到达我的事件处理程序之前在请求对象上执行。我可以明确地将它们称为midwhere,但我需要首先将HTTPRequest对象转换为Django HttpRequest或Django WSGIRequest对象。有关如何实现这一目标的任何建议?

1 个解决方案

#1


1  

Tornado has WSGIContainer, which "makes a WSGI-compatible function runnable on Tornado’s HTTP server" and "-- intended to let other frameworks (Django, web.py, etc) run on the Tornado HTTP server and I/O loop."

Tornado有WSGIContainer,它“使一个WSGI兼容的函数可以在Tornado的HTTP服务器上运行”和“ - 旨在让其他框架(Django,web.py等)在Tornado HTTP服务器和I / O循环上运行。”

#1


1  

Tornado has WSGIContainer, which "makes a WSGI-compatible function runnable on Tornado’s HTTP server" and "-- intended to let other frameworks (Django, web.py, etc) run on the Tornado HTTP server and I/O loop."

Tornado有WSGIContainer,它“使一个WSGI兼容的函数可以在Tornado的HTTP服务器上运行”和“ - 旨在让其他框架(Django,web.py等)在Tornado HTTP服务器和I / O循环上运行。”