API
Guide
Working with WebDAV
DocMoto is a standards based WebDAV server. As such it is possible to work with DocMoto using standard WebDAV commands and an http mechanism such as curl. Full details of the WebDAV specification and code samples are available here.
Connecting to the DocMoto Server
We recommend connecting to DocMoto on port 4983 (insecure) or 4984 (secure). These ports support pure WebDAV unlike the ports used by the DocMoto client (3983 and 3984).
Python API Utilities
The file LwpMotoUtils.py provides a set of utilities for connecting and working with DocMoto via WebDAV. We have an article detailing its usage here.
Setting properties
WebDAV properties are DocMoto tags. Using standard WebDAV calls you can set tag values or run DocMoto templates.
Properties are set using the PROPPATCH command. When adding a value for a property care must be taken to select the correct namespace.
The general form for setting a property is as follows
<prop> <mytagname xmlns="MyTagNamespace:">MyTagValue</mytagname> </prop>
The following code sets the comment tag with a value of "Some comments"
request = """<!--?xml version='1.0' encoding='utf-8'?--> <propertyupdate xmlns="DAV:" xmlns:dm="http://www.docmoto.com/2008/03/uiconfig"> <set> <prop> <comment xmlns="DAV:">Some comments</comment> </prop> </set> </propertyupdate>""" # Confirm LwpMotoUtils.createPropPatch(myURL, request)
A tag's correct namespace and name can be found under the Advanced settings in DocMoto's Tag Manager.
Multiple properties can be set with one call as follows:
request = """<!--?xml version='1.0' encoding='utf-8'?--> <propertyupdate xmlns="DAV:" xmlns:dm="http://www.docmoto.com/2008/03/uiconfig"> <set> <prop> <status xmlns="DMUSER:">Draft</status> </prop> <prop> <clientid xmlns="DMUSER:">1234</clientid> </prop> <prop> <comment xmlns="DAV:">Some comments</comment> </prop> </set> </propertyupdate>""" # Confirm LwpMotoUtils.createPropPatch(myURL, request)
Note, tags with namespace DAV should be listed last when adding multiple properties
Calling Templates
Templates can be called immediately after creating a folder (MKCOL).
The tag Template_Name must be used, and the value should be the template's XML definition file held in the Templates folder within the DocMotoConfig folder.
The Template_Name tag has no namespace.
An example of calling a template is as follows:
# Templates can only be called immediately after creating a folder LwpMotoUtils.createCollection(myURL) request = """<!--?xml version='1.0' encoding='utf-8'?--> <propertyupdate xmlns="DAV:" xmlns:dm="http://www.docmoto.com/2008/03/uiconfig"> <set> <prop> <template_name xmlns="">/DocMotoConfig/Templates/mytemplate.template.xml</template_name> </prop> </set> </propertyupdate>""" # Confirm LwpMotoUtils.createPropPatch(myURL, request)