WebDAV server with TwistedMatrix - Part 2 / X

this is a follow-up to WebDAV server with TwistedMatrix -- Part 1 / X where i have cleaned up the code somewhat. i can hardly believe that this is actually all you need to do:

from twisted.internet import reactor
from twisted.web2.dav import static
from twisted.web2 import server, channel

site = server.Site(static.DAVFile("/Users/vincent/Desktop/test"))
9998, channel.HTTPFactory(site))

you can now connect to your localhost on port 9998.

there are a few catches, though:
  • the twisted dav server is only DAV-level 1 compliant (i.e. it doesn't support locking). However, clients such as OS X 10.4's built-in DAV client require level 2 compliance (not that they really need it). a workaround is the following: in twisted/web2/dav/ change the following line as indicated in the comment:
    def davComplianceClasses(self): 
    return ("1",) # Add "2" when we have locking
  • OS X 10.3's built-in client (and likely 10.4's as well) as well as a bunch of other ones don't support redirection, which twisted does for requests on directories performed with a trailing "/" on the URI. consequently, directories are not (properly) rendered by the OS X 10.3 client (see the ticket). A workaround is to comment out the return RedirectResponse in twisted/web2/dav/ .
Related Entries:
WebDAV server with TwistedMatrix -Part 1 / X


No new comments allowed (anymore) on this post. twisting values since 1994