OPSI.web2.dav.resource module

WebDAV resources.

class OPSI.web2.dav.resource.DAVPropertyMixIn

Bases: OPSI.web2.static.MetaDataMixin

Mix-in class which implements the DAV property access API in L{IDAVResource}.

There are three categories of DAV properties, for the purposes of how this class manages them. A X{property} is either a X{live property} or a X{dead property}, and live properties are split into two categories:

  1. Dead properties. There are properties that the server simply stores as opaque data. These are store in the X{dead property store}, which is provided by subclasses via the L{deadProperties} method.
  2. Live properties which are always computed. These properties aren’t stored anywhere (by this class) but instead are derived from the resource state or from data that is persisted elsewhere. These are listed in the L{liveProperties} attribute and are handled explicitly by the L{readProperty} method.
  3. Live properties may be acted on specially and are stored in the X{dead property store}. These are not listed in the L{liveProperties} attribute, but may be handled specially by the property access methods. For example, L{writeProperty} might validate the data and refuse to write data it deems inappropriate for a given property.

There are two sets of property access methods. The first group (L{hasProperty}, etc.) provides access to all properties. They automatically figure out which category a property falls into and act accordingly.

The second group (L{hasDeadProperty}, etc.) accesses the dead property store directly and bypasses any live property logic that exists in the first group of methods. These methods are used by the first group of methods, and there are cases where they may be needed by other methods. I{Accessing dead properties directly should be done with caution.} Bypassing the live property logic means that values may not be the correct ones for use in DAV requests such as PROPFIND, and may be bypassing security checks. In general, one should never bypass the live property logic as part of a client request for property data.

Properties in the L{twisted_private_namespace} namespace are internal to the server and should not be exposed to clients. They can only be accessed via the dead property store.

contentType()
deadProperties()

Provides internal access to the WebDAV dead property store. You probably shouldn’t be calling this directly if you can use the property accessors in the L{IDAVResource} API instead. However, a subclass must override this method to provide it’s own dead property store.

This implementation returns an instance of L{NonePropertyStore}, which cannot store dead properties. Subclasses must override this method if they wish to store dead properties.

@return: a dict-like object from which one can read and to which one can
write dead properties. Keys are qname tuples (ie. C{(namespace, name)}) as returned by L{davxml.WebDAVElement.qname()} and values are L{davxml.WebDAVElement} instances.
displayName()
hasDeadProperty(property)

Same as L{hasProperty}, but bypasses the live property store and checks directly from the dead property store.

hasProperty(property, request)

See L{IDAVResource.hasProperty}.

listAllprop(request)

Some DAV properties should not be returned to a C{DAV:allprop} query. RFC 3253 defines several such properties. This method computes a subset of the property qnames returned by L{listProperties} by filtering out elements whose class have the C{.hidden} attribute set to C{True}. @return: a list of qnames of properties which are defined and are

appropriate for use in response to a C{DAV:allprop} query.
listProperties(request)

See L{IDAVResource.listProperties}.

liveProperties = (('DAV:', 'resourcetype'), ('DAV:', 'getetag'), ('DAV:', 'getcontenttype'), ('DAV:', 'getcontentlength'), ('DAV:', 'getlastmodified'), ('DAV:', 'creationdate'), ('DAV:', 'displayname'), ('DAV:', 'supportedlock'), ('DAV:', 'acl-restrictions'), ('http://twistedmatrix.com/xml_namespace/dav/', 'resource-class'))
readDeadProperty(property)

Same as L{readProperty}, but bypasses the live property store and reads directly from the dead property store.

readProperty(property, request)

See L{IDAVResource.readProperty}.

removeDeadProperty(property)

Same as L{removeProperty}, but bypasses the live property store and acts directly on the dead property store.

removeProperty(property, request)

See L{IDAVResource.removeProperty}.

writeDeadProperty(property)

Same as L{writeProperty}, but bypasses the live property store and writes directly to the dead property store. Note that this should not be used unless you know that you are writing to an overrideable live property, as this bypasses the logic which protects protected properties. The result of writing to a non-overrideable live property with this method is undefined; the value in the dead property store may or may not be ignored when reading the property with L{readProperty}.

writeProperty(property, request)

See L{IDAVResource.writeProperty}.

class OPSI.web2.dav.resource.DAVResource

Bases: OPSI.web2.dav.resource.DAVPropertyMixIn, OPSI.web2.static.StaticRenderMixin

accessControlList()

See L{IDAVResource.accessControlList}.

This implementation returns an ACL granting all privileges to all principals.

davComplianceClasses()

This implementation raises L{NotImplementedError}. @return: a sequence of strings denoting WebDAV compliance classes. For

example, a DAV level 2 server might return (“1”, “2”).
findChildren(depth)

See L{IDAVResource.findChildren}.

This implementation raises returns C{()} if C{depth} is C{0} and this resource is a collection. Otherwise, it raises L{NotImplementedError}; a subclass must override this method.

isCollection()

See L{IDAVResource.isCollection}.

This implementation raises L{NotImplementedError}; a subclass must override this method.

principalCollections()

See L{IDAVResource.principalCollections}.

This implementation returns C{()}.

renderHTTP(request)
supportedPrivileges()

See L{IDAVResource.supportedPrivileges}.

This implementation returns a supported privilege set containing only the DAV:all privilege.

class OPSI.web2.dav.resource.DAVLeafResource

Bases: OPSI.web2.dav.resource.DAVResource, OPSI.web2.resource.LeafResource

DAV resource with no children.

findChildren(depth)