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 modules: connection and client
The connection module itself has four classes: Connection, Client, LockToken and Property
The Connection class is for setting up a connection object and using it to send HTTP requests to a WebDAV server.
The Client class contains methods for getting and parsing WebDAV responses.
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.
This class deals with WebDAV properties.
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_object = python_webdav.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='.')