예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
    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
예제 #4
0
    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(),))
예제 #5
0
    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(), ))
예제 #6
0
    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
예제 #7
0
    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
예제 #8
0
    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