The idea behind the python-webdav library is to provide developers with an easy to use library that can also allow for a finer grain of control when needed.
The library currently contains two main modules: connection and client
The connection module itself has three classes: Connection, Client and LockToken.
The Connection class is for setting up a connection object and using it to send HTTP requests to a WebDAV server.
It is a low level class that is meant for direct communication with the server.
The Client class contains methods for getting and parsing WebDAV responses. It mainly ustilises the Connection class but is a bit more user friendly.
It uses the parse module to create Resource objects that contain the information about each WebDAV resource.
Lock tokens are used to aid in basic access control for files contained on a WebDAV server. This is a simple class for containing a lock token as an object.
Note
Currently locks are not implemented.
To import the library, use:
import python_webdav
Using the basic functionality of the library is simple. Start by making a Client object:
import python_webdav.client as pywebdav_client
client_object = pywebdav_client.Client('https://webdav.example.net/')
client_object.set_connection(username='KingArthur', password='HolyGrail')
This will set up a Client object that will communicate with the given server and credentials.
The idea of setting up the server and authentication information seperately, is to allow the connection to be used for different users, instead of havingto create individual connections for each user.
To download a file:
import python_webdav
client_object = python_webdav.Client('https://webdav.example.net/')
client_object.set_connection(username='KingArthur', password='HolyGrail')
client_object.download_file('some_file.txt', dest_path='.')