Django ws

1,397 views

Published on

Presentation about Websocket usage within Python projects, using txWebsocket, Twisted and Django.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,397
On SlideShare
0
From Embeds
0
Number of Embeds
397
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Django ws

  1. 1. Django WSBuilding Single-page web-applications with Django, Twisted and TxWebsocket Jeroen van Veen
  2. 2. Websockets?● Persistent TCP connection browser-server● Data exchange ○ Handshake protocol (currently Hybi-16) ○ Both UTF-8-encoded & binary data ○ Low latency, no headers ○ Easy serializing with JSON● Support ○ Python: TxWebsocket, Autobahn WS, Gevent-websocket ○ Browser: Chrome, Firefox, Opera, Safari, IE10 ○ Browser fallback: Flash Websocket
  3. 3. Multi-page VSSingle-page
  4. 4. Bootstrapping● Each url routes initially to the HTML/JS bootstrap view● The websocket connection is initialized● During the handshake, the sessionid cookie is being reused● Set transport.user and add the transport to the client Pool● Signals are used to notify listening code for events like connect, disconnect, view_changed, etc.● The navigation-bar URL is routed through the javascript application and gets the appropriate content
  5. 5. URL Routing● Mimick Django URL routing serverside● And clientside...● XRegexp for named group support● Usable with HTML5 history API● Capture link click events● Client URL tracking and signalling
  6. 6. Django-WS● Django authentication during handshake with session cookie● Client transport pool handling● Event subscription (f.i. client connect,disconnect)● Websocket URL-routing protocol● Twisted MultiFile for static resources & management commands to integrate Twisted in Django● dws namespace, seperate python modules● Clientside RequireJS modules● BSD license
  7. 7. In development● Django-ws modules: core, misc, blog, wiki● Narrowcaster● ...
  8. 8. Challenges● Integrate further with Django ○ Use existing conventions where possible ○ Compatibility modus for HTTP-based Django apps● Cleanup design● Proper documentation● Usable reference Websocket CMS● Community● SEO
  9. 9. Questions? Code https://github.com/phrearch/django-ws-core Contact vanveen@gw20e.com https://twitter.com/#!/jeroen_van_veen

×