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
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"))
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))
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))