Share
Embed
Davvy: Django, WebDAV e (pessimo) stato dell'arte
My talk at Italian Pycon SEI (2015).
Adriano Di Luzio
April 18, 2015
Transcript
27 slides
-
DAVVY DJANGO, WEBDAV E (PESSIMO) STATO DELL'ARTE Adriano Di Luzio
Sabato 18 Aprile 2015 - Firenze - PYCONSEI -
ABOUT ME Software Developer - Unbit, Roma Studente - Informatica
Magistrale @ Sapienza www.github.com/aldur www.twitter.com/AdrianoDiLuzio 2 -
WEBDAV: WHAT? • Web Distributed Authoring and Versioning [1] •
Estensione di HTTP • Il web - medium per lettura e scrittura 4 [1] rfc4918 -
WEBDAV: WHO? Apple (OS X & iOS clients) Google (Android
Calendars, Contacts) E molte altre implementazioni. 5 -
WEBDAV: HOW? 6 HTTP / WebDAV Request PROPFIND (XML) HTTP
/ WebDAV Response PROPFIND (XML) HTTP / WebDAV Request MKCOL … -
HAI DETTO XML? <D:prop xmlns:D='DAV:'><author
xml:lang='en' xmlns:x='http://example.com/ns' xmlns='http://example.com/ns' xmlns:h='http://www.w3.org/1999/xhtml'> <x:name>Jane Doe</x:name> <x:uri added="2005-‐11-‐26" type="email" >mailto:[email protected]</x:uri> <x:uri added="2005-‐11-‐27" type="web" >http://www.example.com</x:uri> <x:notes> Jane has been working way <h:em>too</h:em> long on the long-‐awaited revision of <RFC2518>. </x:notes> </author> </D:prop> 7 -
XML & HTTP: RICHIESTA PROPFIND /container/ HTTP/1.1 Host: www.example.com
Content-‐Type: application/xml; charset="utf-‐8" Content-‐Length: xxxx <?xml version="1.0" encoding="utf-‐8" ?> <propfind xmlns="DAV:"> <propname/> </propfind> 8 -
XML & HTTP: RISPOSTA HTTP/1.1 207 Multi-‐Status Content-‐Type: application/xml;
charset="utf-‐8" Content-‐Length: xxxx <?xml version="1.0" encoding="utf-‐8" ?> <multistatus xmlns="DAV:"> <response> <href>http://www.example.com/container/</href> <propstat> <prop xmlns:R="http://ns.example.com/boxschema/"> <R:author/> <creationdate/> <displayname/> <resourcetype/> </prop> <status>HTTP/1.1 200 OK</status> </propstat> </response> <!-‐-‐ ... -‐-‐> </multistatus> 9 -
Storage DJANGO & DAVVY Architettura e paradigmi 10 Model View
Properties XML → WebDAV Model → XML Resources Collections -
DAVVY: DETTAGLI • Python 2 / Python 3. • Estendibile
a piacimento (Class-View based) • Condivisione / protezione delle risorse. 11 -
DAVVY: SET-UP # settings.py DAVVY_STORAGE_PATH = '/var/www/davvy' 12 #
urls.py from davvy.base import WebDAV from davvy.addressbook import CardDAV from davvy.calendar import CalDAV urlpatterns = patterns('', url(r'^principals/(\w+)/(.*)', WebDAV.as_view(root='storage')), url(r'^storage/(\w+)/(.*)', WebDAV.as_view(root='storage')), url(r'^addressbook/(\w+)/(.*)', CardDAV.as_view(root='addressbook001')), url(r'^calendars/(\w+)/(.*)', CalDAV.as_view(root='calendars')), url(r'^admin/', include(admin.site.urls)), ) -
DAVVY: CUSTOMDAV 13 class CustomDAV(WebDAV): def __init__(self,
**kwargs): self.http_method_names = WebDAV.http_method_names + \ ['custom'] super(CalDAV, self).__init__(**kwargs) def propfind(self, request, user, resource_name): return super(CalDAV, self).propfind( request, user, resource_name, shared=True) def put(self, request, user, resource_name): return super(CalDAV, self).put(request, user, resource_name) # […] def custom(self, request, user, resource_name): # A custom HTTP/WebDAV method! pass -
LO STATO DELL’ARTE L’INCUBO: I CLIENT 14 OS X Calendar
Mozilla Thunderbird -
OS X CALENDAR • Homesets Autodiscovery • Richieste volanti (PROPFIND
/) • .well-known/{caldav, carddav} 15 -
MOZILLA THUNDERBIRD 1. Nessun supporto out-of-the-box. 2. Lightning Calendar Extension.
3. Nessun supporto i’ll-build-the-box. 16 -
CONCLUSIONI • Abbiamo imparato molto… • …soprattutto a stare lontani
da WebDAV! • Nonostante questo, Davvy funziona! • Almeno fino al prossimo giro di client. 22