예제 #1
0
    def __init__(self, code, error):
        """
        @param code: a response code.
        @param error: an L{davxml.WebDAVElement} identifying the error, or a
            tuple C{(namespace, name)} with which to create an empty element
            denoting the error.  (The latter is useful in the case of
            preconditions ans postconditions, not all of which have defined
            XML element classes.)
        """
        if type(error) is tuple:
            xml_namespace, xml_name = error

            class EmptyError(davxml.WebDAVEmptyElement):
                namespace = xml_namespace
                name = xml_name

            error = EmptyError()

        output = davxml.Error(error).toxml()

        Response.__init__(self, code=code, stream=output)

        self.headers.setHeader("content-type", MimeType("text", "xml"))

        self.error = error
예제 #2
0
    def __init__(self, xml_responses):
        """
        @param xml_responses: an interable of davxml.Response objects.
        """
        multistatus = davxml.MultiStatus(*xml_responses)
        output = multistatus.toxml()

        Response.__init__(self,
                          code=responsecode.MULTI_STATUS,
                          stream=davxml.MultiStatus(*xml_responses).toxml())

        self.headers.setHeader("content-type", MimeType("text", "xml"))
예제 #3
0
파일: errors.py 프로젝트: wilane/openxcap
    def __init__(self, code, output):
        """
        @param code: a response code in L{responsecode.RESPONSES}.
        @param output: the body to be attached to the response
        """

        output = output.encode("utf-8")
        mime_params = {"charset": "utf-8"}

        Response.__init__(self, code=code, stream=output)

        ## Its MIME type, registered by this specification, is "application/xcap-error+xml".
        self.headers.setHeader("content-type", http_headers.MimeType("application", "xcap-error+xml", mime_params))
예제 #4
0
    def __init__(self, code, output):
        """
        @param code: a response code in L{responsecode.RESPONSES}.
        @param output: the body to be attached to the response
        """

        output = output.encode("utf-8")
        mime_params = {"charset": "utf-8"}

        Response.__init__(self, code=code, stream=output)

        ## Its MIME type, registered by this specification, is "application/xcap-error+xml".
        self.headers.setHeader(
            "content-type",
            http_headers.MimeType("application", "xcap-error+xml",
                                  mime_params))