Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Davvy: Django, WebDAV e (pessimo) stato dell'arte

Davvy: Django, WebDAV e (pessimo) stato dell'arte

My talk at Italian Pycon SEI (2015).

Adriano Di Luzio

April 18, 2015
Tweet

More Decks by Adriano Di Luzio

Other Decks in Technology

Transcript

  1. ABOUT ME Software Developer - Unbit, Roma Studente - Informatica

    Magistrale @ Sapienza www.github.com/aldur www.twitter.com/AdrianoDiLuzio 2
  2. WEBDAV: WHAT? • Web Distributed Authoring and Versioning [1] •

    Estensione di HTTP • Il web - medium per lettura e scrittura 4 [1] rfc4918
  3. WEBDAV: WHO? Apple (OS X & iOS clients) Google (Android

    Calendars, Contacts) E molte altre implementazioni. 5
  4. WEBDAV: HOW? 6 HTTP / WebDAV Request PROPFIND (XML) HTTP

    / WebDAV Response PROPFIND (XML) HTTP / WebDAV Request MKCOL …
  5. 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  &lt;RFC2518&gt;.                    </x:notes>                </author>            </D:prop> 7
  6. 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
  7. 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
  8. Storage DJANGO & DAVVY Architettura e paradigmi 10 Model View

    Properties XML → WebDAV Model → XML Resources Collections
  9. DAVVY: DETTAGLI • Python 2 / Python 3. • Estendibile

    a piacimento (Class-View based) • Condivisione / protezione delle risorse. 11
  10. 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)),   )
  11. 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  
  12. CONCLUSIONI • Abbiamo imparato molto… • …soprattutto a stare lontani

    da WebDAV! • Nonostante questo, Davvy funziona! • Almeno fino al prossimo giro di client. 22