def getProperties(self, rurl, props, xmldata=False): assert (isinstance(rurl, URL)) results = {} bad = None # Create WebDAV propfind if props: request = PropFind(self, rurl.relativeURL(), headers.Depth0, props) else: request = PropAll(self, rurl.relativeURL(), headers.Depth0) result = ResponseDataString() request.setOutput(result) # Process it self.runSession(request) # If its a 207 we want to parse the XML if request.getStatusCode() == statuscodes.MultiStatus: parser = PropFindParser() parser.parseData(result.getData()) # Look at each propfind result for item in parser.getResults().itervalues(): # Get child element name (decode URL) name = URL(url=item.getResource(), decode=True) # Must match rurl if name.equalRelative(rurl): for name, value in item.getTextProperties().iteritems(): results[name] = value for name, value in item.getHrefProperties().iteritems(): if name not in results: results[name] = value for name, value in item.getNodeProperties().iteritems(): if name not in results: results[name] = tostring( value) if xmldata else value bad = item.getBadProperties() else: self.handleHTTPError(request) return results, bad
def getProperties(self, rurl, props, xmldata=False): assert(isinstance(rurl, URL)) results = {} bad = None # Create WebDAV propfind if props: request = PropFind(self, rurl.relativeURL(), headers.Depth0, props) else: request = PropAll(self, rurl.relativeURL(), headers.Depth0) result = ResponseDataString() request.setOutput(result) # Process it self.runSession(request) # If its a 207 we want to parse the XML if request.getStatusCode() == statuscodes.MultiStatus: parser = PropFindParser() parser.parseData(result.getData()) # Look at each propfind result for item in parser.getResults().itervalues(): # Get child element name (decode URL) name = URL(url=item.getResource(), decode=True) # Must match rurl if name.equalRelative(rurl): for name, value in item.getTextProperties().iteritems(): results[name] = value for name, value in item.getHrefProperties().iteritems(): if name not in results: results[name] = value for name, value in item.getNodeProperties().iteritems(): if name not in results: results[name] = tostring(value) if xmldata else value bad = item.getBadProperties() else: self.handleHTTPError(request) return results, bad
def getHrefListProperty(self, rurl, propname): assert (isinstance(rurl, URL)) results = () # Create WebDAV propfind request = PropFind(self, rurl.relativeURL(), headers.Depth0, (propname, )) result = ResponseDataString() request.setOutput(result) # Process it self.runSession(request) # If its a 207 we want to parse the XML if request.getStatusCode() == statuscodes.MultiStatus: parser = PropFindParser() parser.parseData(result.getData()) # Look at each propfind result and extract any Hrefs for item in parser.getResults().itervalues(): # Get child element name (decode URL) name = URL(url=item.getResource(), decode=True) # Must match the URL the request was actually targeted at if name.equalRelative(URL(url=request.url)): if str(propname) in item.getNodeProperties(): propnode = item.getNodeProperties()[str(propname)] results += tuple([ URL(url=href.text, decode=True) for href in propnode.findall(str(davxml.href)) if href.text ]) else: self.handleHTTPError(request) return results
def doRequest(self): """ Execute the actual HTTP request. """ props = ( csxml.invite, ) # Create WebDAV propfind request = PropFind(self.sessions[0], self.sessions[0].calendarHref, self.depth, props) result = ResponseDataString() request.setOutput(result) # Process it self.sessions[0].runSession(request) # If its a 207 we want to parse the XML if request.getStatusCode() == statuscodes.MultiStatus: pass else: raise RuntimeError("Propfind request failed: %s" % (request.getStatusCode(),))
def doRequest(self): """ Execute the actual HTTP request. """ props = (csxml.invite, ) # Create WebDAV propfind request = PropFind(self.sessions[0], self.sessions[0].calendarHref, self.depth, props) result = ResponseDataString() request.setOutput(result) # Process it self.sessions[0].runSession(request) # If its a 207 we want to parse the XML if request.getStatusCode() == statuscodes.MultiStatus: pass else: raise RuntimeError("Propfind request failed: %s" % (request.getStatusCode(), ))
def getPropertiesOnHierarchy(self, rurl, props): assert (isinstance(rurl, URL)) results = {} # Create WebDAV propfind request = PropFind(self, rurl.relativeURL(), headers.Depth1, props) result = ResponseDataString() request.setOutput(result) # Process it self.runSession(request) # If its a 207 we want to parse the XML if request.getStatusCode() == statuscodes.MultiStatus: parser = PropFindParser() parser.parseData(result.getData()) # Look at each propfind result for item in parser.getResults().itervalues(): # Get child element name (decode URL) name = URL(url=item.getResource(), decode=True) propresults = {} results[name.relativeURL()] = propresults for prop in props: if str(prop) in item.getTextProperties(): propresults[prop] = item.getTextProperties().get( str(prop)) elif str(prop) in item.getNodeProperties(): propresults[prop] = item.getNodeProperties()[str(prop)] else: self.handleHTTPError(request) return results
def getPropertiesOnHierarchy(self, rurl, props): assert(isinstance(rurl, URL)) results = {} # Create WebDAV propfind request = PropFind(self, rurl.relativeURL(), headers.Depth1, props) result = ResponseDataString() request.setOutput(result) # Process it self.runSession(request) # If its a 207 we want to parse the XML if request.getStatusCode() == statuscodes.MultiStatus: parser = PropFindParser() parser.parseData(result.getData()) # Look at each propfind result for item in parser.getResults().itervalues(): # Get child element name (decode URL) name = URL(url=item.getResource(), decode=True) propresults = {} results[name.relativeURL()] = propresults for prop in props: if str(prop) in item.getTextProperties(): propresults[prop] = item.getTextProperties().get(str(prop)) elif str(prop) in item.getNodeProperties(): propresults[prop] = item.getNodeProperties()[str(prop)] else: self.handleHTTPError(request) return results
def getHrefListProperty(self, rurl, propname): assert(isinstance(rurl, URL)) results = () # Create WebDAV propfind request = PropFind(self, rurl.relativeURL(), headers.Depth0, (propname,)) result = ResponseDataString() request.setOutput(result) # Process it self.runSession(request) # If its a 207 we want to parse the XML if request.getStatusCode() == statuscodes.MultiStatus: parser = PropFindParser() parser.parseData(result.getData()) # Look at each propfind result and extract any Hrefs for item in parser.getResults().itervalues(): # Get child element name (decode URL) name = URL(url=item.getResource(), decode=True) # Must match rurl if name.equalRelative(rurl): if str(propname) in item.getNodeProperties(): propnode = item.getNodeProperties()[str(propname)] results += tuple([URL(url=href.text, decode=True) for href in propnode.findall(str(davxml.href)) if href.text]) else: self.handleHTTPError(request) return results