Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to understand tornado response request cycle in Django

I want to create a real time twitter streaming application using tornado and Django. The problem is I am not able to understand the role of Tornado here, and how will I use view.py models.py of Django in Tornado Web Server.

Below if the request response cycle of Django, could anybody explain to me how the tornado web server will play its role here. enter image description here

Few questions:

1- What will be role of urls.py file in Django since we will be routing all the urls from Tornado itself.

2- How will I connect to models.py to fetch rows for my tornado application.

I am looking into this github project link

like image 993
python Avatar asked Oct 24 '25 19:10

python


1 Answers

Tornado fits roughly in the "web server" and "wsgi" parts of this diagram, and adds another section for Tornado RequestHandlers attached to the web server. When you create your tornado.web.Application, you will send some URLs to Tornado RequestHandlers and some to the Django WSGIContainer (which will in turn use the Django urls.py).

Using Django models from Tornado code is more challenging; my code from the last time I tried doing this is at https://gist.github.com/bdarnell/654157 (but note that this is quite old and I don't know if it will work any more)

like image 69
Ben Darnell Avatar answered Oct 26 '25 10:10

Ben Darnell