コード例 #1
0
ファイル: __init__.py プロジェクト: joecampos432/openxcap
 def _cb_get_element(self, response, uri):
     """This is called when the document related to the element is retrieved."""
     if response.code == 404:     ## XXX why not let the storage raise?
         raise errors.ResourceNotFound("The requested document %s was not found on this server" % uri.doc_selector)
     result = element.get(response.data, uri.node_selector.element_selector)
     if not result:
         msg = "The requested element %s was not found in the document %s" % (uri.node_selector, uri.doc_selector)
         raise errors.ResourceNotFound(msg)
     return StatusResponse(200, response.etag, result)
コード例 #2
0
ファイル: __init__.py プロジェクト: joecampos432/openxcap
 def _cb_delete_element(self, response, uri, check_etag):
     if response.code == 404:
         raise errors.ResourceNotFound("The requested document %s was not found on this server" % uri.doc_selector)
     new_document = element.delete(response.data, uri.node_selector.element_selector)
     if not new_document:
         raise errors.ResourceNotFound
     get_result = element.find(new_document, uri.node_selector.element_selector)
     if get_result:
         raise errors.CannotDeleteError('DELETE request failed GET(DELETE(x))==404 invariant')
     return self.put_document(uri, new_document, check_etag)
コード例 #3
0
ファイル: __init__.py プロジェクト: joecampos432/openxcap
 def _cb_delete_attribute(self, response, uri, check_etag):
     if response.code == 404:
         raise errors.ResourceNotFound
     document = response.data
     xml_doc = etree.parse(StringIO(document))
     application = getApplicationForURI(uri)
     ns_dict = uri.node_selector.get_ns_bindings(application.default_ns)
     try:
         elem = xml_doc.xpath(uri.node_selector.replace_default_prefix(append_terminal=False),namespaces=ns_dict)
     except Exception, ex:
         ex.http_error = errors.ResourceNotFound()
         raise
コード例 #4
0
ファイル: __init__.py プロジェクト: joecampos432/openxcap
 def _cb_get_ns_bindings(self, response, uri):
     """This is called when the document that relates to the element is retrieved."""
     if response.code == 404:
         raise errors.ResourceNotFound
     document = response.data
     xml_doc = etree.parse(StringIO(document))
     application = getApplicationForURI(uri)
     ns_dict = uri.node_selector.get_ns_bindings(application.default_ns)
     try:
         elem = xml_doc.xpath(uri.node_selector.replace_default_prefix(append_terminal=False),namespaces=ns_dict)
     except Exception, ex:
         ex.http_error =  errors.ResourceNotFound()
         raise
コード例 #5
0
ファイル: capabilities.py プロジェクト: wilane/openxcap
 def put_document(self, uri, document, check_etag):
     raise errors.ResourceNotFound("This application does not support PUT method")
コード例 #6
0
ファイル: __init__.py プロジェクト: joecampos432/openxcap
 def _not_implemented(self, context):
     raise errors.ResourceNotFound("Application %s does not implement %s context" % (self.id, context))
コード例 #7
0
ファイル: __init__.py プロジェクト: joecampos432/openxcap
        if response.code == 404:
            raise errors.ResourceNotFound
        document = response.data
        xml_doc = etree.parse(StringIO(document))
        application = getApplicationForURI(uri)
        ns_dict = uri.node_selector.get_ns_bindings(application.default_ns)
        try:
            xpath = uri.node_selector.replace_default_prefix()
            attribute = xml_doc.xpath(xpath, namespaces = ns_dict)
        except Exception, ex:
            ex.http_error = errors.ResourceNotFound()
            raise
        if not attribute:
            raise errors.ResourceNotFound
        elif len(attribute) != 1:
            raise errors.ResourceNotFound('XPATH expression is ambiguous')
        # TODO
        # The server MUST NOT add namespace bindings representing namespaces
        # used by the element or its children, but declared in ancestor elements
        return StatusResponse(200, response.etag, attribute[0])

    def get_attribute(self, uri, check_etag):
        d = self.get_document(uri, check_etag)
        return d.addCallbacks(self._cb_get_attribute, callbackArgs=(uri, ))

    def _cb_delete_attribute(self, response, uri, check_etag):
        if response.code == 404:
            raise errors.ResourceNotFound
        document = response.data
        xml_doc = etree.parse(StringIO(document))
        application = getApplicationForURI(uri)
コード例 #8
0
ファイル: purge.py プロジェクト: wilane/openxcap
 def delete_document(self, uri, document, check_etag):
     raise errors.ResourceNotFound(
         "This application does not support DELETE method")