/usr/share/pyshared/pywebdav/lib/report.py is in python-webdav 0.9.8-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | from propfind import PROPFIND
from xml.dom import minidom
domimpl = minidom.getDOMImplementation()
from utils import get_parenturi
class REPORT(PROPFIND):
def __init__(self, uri, dataclass, depth, body):
PROPFIND.__init__(self, uri, dataclass, depth, body)
doc = minidom.parseString(body)
self.filter = doc.documentElement
def create_propname(self):
""" create a multistatus response for the prop names """
dc=self._dataclass
# create the document generator
doc = domimpl.createDocument(None, "multistatus", None)
ms = doc.documentElement
ms.setAttribute("xmlns:D", "DAV:")
ms.tagName = 'D:multistatus'
if self._depth=="0":
if self._uri in self._dataclass.get_childs(get_parenturi(self._uri),
self.filter):
pnames=dc.get_propnames(self._uri)
re=self.mk_propname_response(self._uri,pnames, doc)
ms.appendChild(re)
elif self._depth=="1":
if self._uri in self._dataclass.get_childs(get_parenturi(self._uri),
self.filter):
pnames=dc.get_propnames(self._uri)
re=self.mk_propname_response(self._uri,pnames, doc)
ms.appendChild(re)
for newuri in dc.get_childs(self._uri, self.filter):
pnames=dc.get_propnames(newuri)
re=self.mk_propname_response(newuri,pnames, doc)
ms.appendChild(re)
elif self._depth=='infinity':
uri_list = [self._uri]
while uri_list:
uri = uri_list.pop()
if uri in self._dataclass.get_childs(get_parenturi(uri),
self.filter):
pnames=dc.get_propnames(uri)
re=self.mk_propname_response(uri,pnames, doc)
ms.appendChild(re)
uri_childs = self._dataclass.get_childs(uri)
if uri_childs:
uri_list.extend(uri_childs)
return doc.toxml(encoding="utf-8")
def create_prop(self):
""" handle a <prop> request
This will
1. set up the <multistatus>-Framework
2. read the property values for each URI
(which is dependant on the Depth header)
This is done by the get_propvalues() method.
3. For each URI call the append_result() method
to append the actual <result>-Tag to the result
document.
We differ between "good" properties, which have been
assigned a value by the interface class and "bad"
properties, which resulted in an error, either 404
(Not Found) or 403 (Forbidden).
"""
# create the document generator
doc = domimpl.createDocument(None, "multistatus", None)
ms = doc.documentElement
ms.setAttribute("xmlns:D", "DAV:")
ms.tagName = 'D:multistatus'
if self._depth=="0":
if self._uri in self._dataclass.get_childs(get_parenturi(self._uri),
self.filter):
gp,bp=self.get_propvalues(self._uri)
res=self.mk_prop_response(self._uri,gp,bp,doc)
ms.appendChild(res)
elif self._depth=="1":
if self._uri in self._dataclass.get_childs(get_parenturi(self._uri),
self.filter):
gp,bp=self.get_propvalues(self._uri)
res=self.mk_prop_response(self._uri,gp,bp,doc)
ms.appendChild(res)
for newuri in self._dataclass.get_childs(self._uri, self.filter):
gp,bp=self.get_propvalues(newuri)
res=self.mk_prop_response(newuri,gp,bp,doc)
ms.appendChild(res)
elif self._depth=='infinity':
uri_list = [self._uri]
while uri_list:
uri = uri_list.pop()
if uri in self._dataclass.get_childs(get_parenturi(uri),
self.filter):
gp,bp=self.get_propvalues(uri)
res=self.mk_prop_response(uri,gp,bp,doc)
ms.appendChild(res)
uri_childs = self._dataclass.get_childs(uri)
if uri_childs:
uri_list.extend(uri_childs)
return doc.toxml(encoding="utf-8")
|