WebDAV server with TwistedMatrix -Part 1 / X

you can find an updated version of the code presented here in the follow-up post.

apple's wilfredo sanchez recently contributed a working DAV implementation to the twistedmatrix networking framework. i intend to use both DAV and twisted matrix for our upcoming storage framework, so this contribution is just in time. ;-)

being fresh and hot off the press, documentation is sparse to nonexistent, so i intend to document my way through this jungle -- and maybe eventually contribute something back.

i have completed the first step of getting the code about two weeks ago: you'll have to get it from subversion, and then was a bit baffled by how the code tied together. it turns out it's actually quite easy and an hour ago i just got the first (ultra-buggy) self-hosted webdav volume mounted on my mac desktop -- so here you go (

import os.path, time
#from twisted.web2 import server, http, channel, resource
from twisted.web2.dav import static
from twisted.web2 import server, channel, resource
from twisted.web2 import http_headers, responsecode
from twisted.web2.dav import *
from twisted.web2.dav.method import *

site = server.Site(static.DAVFile("/Users/vincent/Desktop"))

# Standard twisted application Boilerplate
from twisted.application import service, strports
application = service.Application("demoserver")
s = strports.service('tcp:9998', channel.HTTPFactory(site))
after setting PATH and PYTHONPATH to the appropriate values, you can then launch the server from the shell using e.g.: twistd -ny
Related Entries:
WebDAV server with TwistedMatrix - Part 2 / X
 Permalink twisting values since 1994