def getrecordbyid(self, id=[], esn='full', outputschema=namespaces['csw'], format=outputformat): """ Construct and process a GetRecordById request Parameters ---------- - id: the list of Ids - esn: the ElementSetName 'full', 'brief' or 'summary' (default is 'full') - outputschema: the outputSchema (default is 'http://www.opengis.net/cat/csw/2.0.2') - format: the outputFormat (default is 'application/xml') """ # construct request node0 = self._setrootelement('csw:GetRecordById') node0.set('outputSchema', outputschema) node0.set('outputFormat', format) node0.set('version', self.version) node0.set('service', self.service) node0.set(util.nspath_eval('xsi:schemaLocation', namespaces), schema_location) for i in id: etree.SubElement(node0, util.nspath_eval('csw:Id', namespaces)).text = i etree.SubElement(node0, util.nspath_eval('csw:ElementSetName', namespaces)).text = esn self.request = util.xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: self.results = {} self.records = {} self._parserecords(outputschema, esn)
def describerecord(self, typename='csw:Record', format=outputformat): """ Construct and process DescribeRecord request Parameters ---------- - typename: the typename to describe (default is 'csw:Record') - format: the outputFormat (default is 'application/xml') """ # construct request nsmap = { 'csw' : ns.get_namespace('csw'), 'xsi' : ns.get_namespace('xsi'), } node0 = setrootelement('csw:DescribeRecord', nsmap) node0.set('outputFormat', format) node0.set('schemaLanguage',ns.get_namespace('xs2')) node0.set('service', self.service) node0.set('version', self.version) node0.set(nsp('xsi:schemaLocation'), schema_location) etree.SubElement(node0, nsp('csw:TypeName')).text = typename self.request = xml2string(etree.tostring(node0)) self._invoke()
def describerecord(self, typename='csw:Record', format=outputformat): """ Construct and process DescribeRecord request Parameters ---------- - typename: the typename to describe (default is 'csw:Record') - format: the outputFormat (default is 'application/xml') """ # construct request node0 = etree.Element( util.nspath_eval('csw:DescribeRecord', namespaces)) node0.set('service', self.service) node0.set('version', self.version) node0.set('outputFormat', format) node0.set('schemaLanguage', namespaces['xs2']) node0.set(util.nspath_eval('xsi:schemaLocation', namespaces), schema_location) etree.SubElement(node0, util.nspath_eval('csw:TypeName', namespaces)).text = typename self.request = util.xml2string(etree.tostring(node0)) self._invoke()
def describerecord(self, typename='csw:Record', format=outputformat): """ Construct and process DescribeRecord request Parameters ---------- - typename: the typename to describe (default is 'csw:Record') - format: the outputFormat (default is 'application/xml') """ # construct request node0 = etree.Element(util.nspath('DescribeRecord', namespaces['csw'])) node0.set('service', self.service) node0.set('version', self.version) node0.set('outputFormat', format) node0.set('schemaLanguage', namespaces['xs2']) node0.set(util.nspath('schemaLocation', namespaces['xsi']), schema_location) etree.SubElement(node0, util.nspath('TypeName', namespaces['csw'])).text = typename self.request = util.xml2string(etree.tostring(node0)) # invoke self.response = util.http_post(self.url, self.request, self.lang)
def _invoke(self): # do HTTP request if isinstance(self.request, basestring): # GET KVP self.response = urlopen(self.request, timeout=self.timeout).read() else: self.request = cleanup_namespaces(self.request) self.request = util.xml2string(etree.tostring(self.request)) self.response = util.http_post(self.url, self.request, self.lang, self.timeout) # parse result see if it's XML self._exml = etree.parse(StringIO.StringIO(self.response)) # it's XML. Attempt to decipher whether the XML response is CSW-ish """ valid_xpaths = [ util.nspath_eval("ows:ExceptionReport", namespaces), util.nspath_eval("csw:Capabilities", namespaces), util.nspath_eval("csw:DescribeRecordResponse", namespaces), util.nspath_eval("csw:GetDomainResponse", namespaces), util.nspath_eval("csw:GetRecordsResponse", namespaces), util.nspath_eval("csw:GetRecordByIdResponse", namespaces), util.nspath_eval("csw:HarvestResponse", namespaces), util.nspath_eval("csw:TransactionResponse", namespaces), ] if self._exml.getroot().tag not in valid_xpaths: raise RuntimeError, "Document is XML, but not CSW-ish" # check if it's an OGC Exception val = self._exml.find(util.nspath_eval("ows:Exception", namespaces)) if val is not None: raise ows.ExceptionReport(self._exml, self.owscommon.namespace) else: self.exceptionreport = None
def getrecordbyid(self, id=[], esn="full", outputschema=namespaces["csw"], format=outputformat): """ Construct and process a GetRecordById request Parameters ---------- - id: the list of Ids - esn: the ElementSetName 'full', 'brief' or 'summary' (default is 'full') - outputschema: the outputSchema (default is 'http://www.opengis.net/cat/csw/2.0.2') - format: the outputFormat (default is 'application/xml') """ # construct request node0 = etree.Element(util.nspath("GetRecordById", namespaces["csw"])) node0.set("outputSchema", outputschema) node0.set("outputFormat", format) node0.set("version", self.version) node0.set("service", self.service) node0.set(util.nspath("schemaLocation", namespaces["xsi"]), schema_location) for i in id: etree.SubElement(node0, util.nspath("Id", namespaces["csw"])).text = i etree.SubElement(node0, util.nspath("ElementSetName", namespaces["csw"])).text = esn self.request = util.xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: self.results = {} self.records = {} self._parserecords(outputschema, esn)
def __init__(self, url, lang='en-US', version='2.0.2', timeout=10, skip_caps=False): """ Construct and process a GetCapabilities request Parameters ---------- - url: the URL of the CSW - lang: the language (default is 'en-US') - version: version (default is '2.0.2') - timeout: timeout in seconds - skip_caps: whether to skip GetCapabilities processing on init (default is False) """ self.url = url self.lang = lang self.version = version self.timeout = timeout self.service = 'CSW' self.exceptionreport = None if not skip_caps: # process GetCapabilities # construct request nsmap = { 'csw' : ns.get_namespace('csw'), 'ows' : ns.get_versioned_namespace('ows',_ows_version), 'xsi' : ns.get_namespace('xsi'), } node0 = setrootelement('csw:GetCapabilities', nsmap) node0.set('service', self.service) node0.set(nsp('xsi:schemaLocation'), schema_location) tmp = etree.SubElement(node0, nsp_ows('ows:AcceptVersions')) etree.SubElement(tmp, nsp_ows('ows:Version')).text = self.version tmp2 = etree.SubElement(node0, nsp_ows('ows:AcceptFormats')) etree.SubElement(tmp2, nsp_ows('ows:OutputFormat')).text = outputformat self.request = xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: # ServiceIdentification val = self._exml.find(nsp_ows('ows:ServiceIdentification')) self.identification=ows.ServiceIdentification(val,ns.get_versioned_namespace('ows', _ows_version)) # ServiceProvider val = self._exml.find(nsp_ows('ows:ServiceProvider')) self.provider=ows.ServiceProvider(val) # ServiceOperations metadata op = self._exml.find(nsp_ows('ows:OperationsMetadata')) self.operations = ows.OperationsMetadata(op, ns.get_versioned_namespace('ows', _ows_version)).operations # FilterCapabilities val = self._exml.find(nsp('ogc:Filter_Capabilities')) self.filters=fes.FilterCapabilities(val)
def harvest(self, source, resourcetype, resourceformat=None, harvestinterval=None, responsehandler=None): """ Construct and process a Harvest request Parameters ---------- - source: a URI to harvest - resourcetype: namespace identifying the type of resource - resourceformat: MIME type of the resource - harvestinterval: frequency of harvesting, in ISO8601 - responsehandler: endpoint that CSW should responsd to with response """ # construct request node0 = etree.Element(util.nspath('Harvest', namespaces['csw'])) node0.set('version', self.version) node0.set('service', self.service) node0.set(util.nspath('schemaLocation', namespaces['xsi']), schema_location) etree.SubElement(node0, util.nspath('Source', namespaces['csw'])).text = source etree.SubElement(node0, util.nspath('ResourceType', namespaces['csw'])).text = resourcetype if resourceformat is not None: etree.SubElement(node0, util.nspath('ResourceFormat', namespaces['csw'])).text = resourceformat if harvestinterval is not None: etree.SubElement(node0, util.nspath('HarvestInterval', namespaces['csw'])).text = harvestinterval if responsehandler is not None: etree.SubElement(node0, util.nspath('ResponseHandler', namespaces['csw'])).text = responsehandler self.request = util.xml2string(etree.tostring(node0)) self.response = util.http_post(self.url, self.request, self.lang) # parse result self._response = etree.parse(StringIO.StringIO(self.response)) # check for exceptions self._isexception(self._response, self.owscommon.namespace) self.results = {} if self.exceptionreport is None: val = self._response.find(util.nspath('Acknowledgement', namespaces['csw'])) if util.testXMLValue(val) is not None: ts = val.attrib.get('timeStamp') self.timestamp = util.testXMLValue(ts, True) id = val.find(util.nspath('RequestId', namespaces['csw'])) self.id = util.testXMLValue(id) else: self._parsetransactionsummary() self.results['inserted'] = [] for i in self._response.findall(util.nspath('TransactionResponse/InsertResult', namespaces['csw'])): for j in i.findall(util.nspath('BriefRecord', namespaces['csw']) + '/' + util.nspath('identifier', namespaces['dc'])): self.results['inserted'].append(util.testXMLValue(j))
def __init__(self, url, lang='en-US', version='2.0.2'): """ Construct and process a GetCapabilities request Parameters ---------- - url: the URL of the CSW - lang: the language (default is 'en-US') - version: version (default is '2.0.2') """ self.url = url self.lang = lang self.version = version self.service = 'CSW' self.exceptionreport = None self.owscommon = OwsCommon('1.0.0') # construct request node0 = etree.Element(util.nspath('GetCapabilities', namespaces['csw'])) node0.set('service', self.service) node0.set(util.nspath('schemaLocation', namespaces['xsi']), schema_location) tmp = etree.SubElement(node0, util.nspath('AcceptVersions', namespaces['ows'])) etree.SubElement(tmp, util.nspath('Version', namespaces['ows'])).text = self.version tmp2 = etree.SubElement(node0, util.nspath('AcceptFormats', namespaces['ows'])) etree.SubElement(tmp2, util.nspath('OutputFormat', namespaces['ows'])).text = outputformat self.request = util.xml2string(etree.tostring(node0)) # invoke self.response = util.http_post(self.url, self.request, self.lang) # parse result self._capabilities = etree.parse(StringIO.StringIO(self.response)) # check for exceptions self._isexception(self._capabilities, self.owscommon.namespace) if self.exceptionreport is None: # ServiceIdentification val = self._capabilities.find(util.nspath('ServiceIdentification', namespaces['ows'])) self.identification=ServiceIdentification(val,self.owscommon.namespace) # ServiceProvider val = self._capabilities.find(util.nspath('ServiceProvider', namespaces['ows'])) self.provider=ServiceProvider(val,self.owscommon.namespace) # ServiceOperations metadata self.operations=[] for elem in self._capabilities.findall(util.nspath('OperationsMetadata/Operation', namespaces['ows'])): self.operations.append(OperationsMetadata(elem, self.owscommon.namespace)) # FilterCapabilities val = self._capabilities.find(util.nspath('Filter_Capabilities', namespaces['ogc'])) self.filters=FilterCapabilities(val)
def __init__(self, url, lang='en-US', version='2.0.2', timeout=10, skip_caps=False): """ Construct and process a GetCapabilities request Parameters ---------- - url: the URL of the CSW - lang: the language (default is 'en-US') - version: version (default is '2.0.2') - timeout: timeout in seconds - skip_caps: whether to skip GetCapabilities processing on init (default is False) """ self.url = url self.lang = lang self.version = version self.timeout = timeout self.service = 'CSW' self.exceptionreport = None self.owscommon = ows.OwsCommon('1.0.0') if not skip_caps: # process GetCapabilities # construct request node0 = self._setrootelement('csw:GetCapabilities') node0.set('service', self.service) node0.set(util.nspath_eval('xsi:schemaLocation', namespaces), schema_location) tmp = etree.SubElement(node0, util.nspath_eval('ows:AcceptVersions', namespaces)) etree.SubElement(tmp, util.nspath_eval('ows:Version', namespaces)).text = self.version tmp2 = etree.SubElement(node0, util.nspath_eval('ows:AcceptFormats', namespaces)) etree.SubElement(tmp2, util.nspath_eval('ows:OutputFormat', namespaces)).text = outputformat self.request = util.xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: # ServiceIdentification val = self._exml.find(util.nspath_eval('ows:ServiceIdentification', namespaces)) self.identification=ows.ServiceIdentification(val,self.owscommon.namespace) # ServiceProvider val = self._exml.find(util.nspath_eval('ows:ServiceProvider', namespaces)) self.provider=ows.ServiceProvider(val,self.owscommon.namespace) # ServiceOperations metadata self.operations=[] for elem in self._exml.findall(util.nspath_eval('ows:OperationsMetadata/ows:Operation', namespaces)): self.operations.append(ows.OperationsMetadata(elem, self.owscommon.namespace)) # FilterCapabilities val = self._exml.find(util.nspath_eval('ogc:Filter_Capabilities', namespaces)) self.filters=fes.FilterCapabilities(val)
def getdomain(self, dname, dtype='parameter'): """ Construct and process a GetDomain request Parameters ---------- - dname: the value of the Parameter or Property to query - dtype: whether to query a parameter (parameter) or property (property) """ # construct request dtypename = 'ParameterName' node0 = etree.Element(util.nspath_eval('csw:GetDomain', namespaces)) node0.set('service', self.service) node0.set('version', self.version) node0.set(util.nspath_eval('xsi:schemaLocation', namespaces), schema_location) if dtype == 'property': dtypename = 'PropertyName' etree.SubElement(node0, util.nspath_eval('csw:%s' % dtypename, namespaces)).text = dname self.request = util.xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: self.results = {} val = self._exml.find( util.nspath_eval('csw:DomainValues', namespaces)).attrib.get('type') self.results['type'] = util.testXMLValue(val, True) val = self._exml.find( util.nspath_eval('csw:DomainValues/csw:%s' % dtypename, namespaces)) self.results[dtype] = util.testXMLValue(val) # get the list of values associated with the Domain self.results['values'] = [] for f in self._exml.findall( util.nspath_eval( 'csw:DomainValues/csw:ListOfValues/csw:Value', namespaces)): self.results['values'].append(util.testXMLValue(f))
def __init__(self, url, lang="en-US", version="2.0.2", timeout=10): """ Construct and process a GetCapabilities request Parameters ---------- - url: the URL of the CSW - lang: the language (default is 'en-US') - version: version (default is '2.0.2') - timeout: timeout in seconds """ self.url = url self.lang = lang self.version = version self.timeout = timeout self.service = "CSW" self.exceptionreport = None self.owscommon = OwsCommon("1.0.0") # construct request node0 = etree.Element(util.nspath("GetCapabilities", namespaces["csw"])) node0.set("service", self.service) node0.set(util.nspath("schemaLocation", namespaces["xsi"]), schema_location) tmp = etree.SubElement(node0, util.nspath("AcceptVersions", namespaces["ows"])) etree.SubElement(tmp, util.nspath("Version", namespaces["ows"])).text = self.version tmp2 = etree.SubElement(node0, util.nspath("AcceptFormats", namespaces["ows"])) etree.SubElement(tmp2, util.nspath("OutputFormat", namespaces["ows"])).text = outputformat self.request = util.xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: # ServiceIdentification val = self._exml.find(util.nspath("ServiceIdentification", namespaces["ows"])) self.identification = ServiceIdentification(val, self.owscommon.namespace) # ServiceProvider val = self._exml.find(util.nspath("ServiceProvider", namespaces["ows"])) self.provider = ServiceProvider(val, self.owscommon.namespace) # ServiceOperations metadata self.operations = [] for elem in self._exml.findall(util.nspath("OperationsMetadata/Operation", namespaces["ows"])): self.operations.append(OperationsMetadata(elem, self.owscommon.namespace)) # FilterCapabilities val = self._exml.find(util.nspath("Filter_Capabilities", namespaces["ogc"])) self.filters = FilterCapabilities(val)
def getdomain(self, dname, dtype='parameter'): """ Construct and process a GetDomain request Parameters ---------- - dname: the value of the Parameter or Property to query - dtype: whether to query a parameter (parameter) or property (property) """ # construct request dtypename = 'ParameterName' node0 = etree.Element(util.nspath('GetDomain', namespaces['csw'])) node0.set('service', self.service) node0.set('version', self.version) node0.set(util.nspath('schemaLocation', namespaces['xsi']), schema_location) if dtype == 'property': dtypename = 'PropertyName' etree.SubElement(node0, util.nspath(dtypename, namespaces['csw'])).text = dname self.request = util.xml2string(etree.tostring(node0)) # invoke self.response = util.http_post(self.url, self.request, self.lang) # parse result self._values = etree.parse(StringIO.StringIO(self.response)) # check for exceptions self._isexception(self._values, self.owscommon.namespace) if self.exceptionreport is None: self.results = {} val = self._values.find(util.nspath('DomainValues', namespaces['csw'])).attrib.get('type') self.results['type'] = util.testXMLValue(val, True) val = self._values.find(util.nspath('DomainValues/' + dtypename, namespaces['csw'])) self.results[dtype] = util.testXMLValue(val) # get the list of values associated with the Domain self.results['values'] = [] for f in self._values.findall(util.nspath('DomainValues/ListOfValues/Value', namespaces['csw'])): self.results['values'].append(util.testXMLValue(f))
def harvest(self, source, resourcetype, resourceformat=None, harvestinterval=None, responsehandler=None): """ Construct and process a Harvest request Parameters ---------- - source: a URI to harvest - resourcetype: namespace identifying the type of resource - resourceformat: MIME type of the resource - harvestinterval: frequency of harvesting, in ISO8601 - responsehandler: endpoint that CSW should responsd to with response """ # construct request node0 = etree.Element(util.nspath("Harvest", namespaces["csw"])) node0.set("version", self.version) node0.set("service", self.service) node0.set(util.nspath("schemaLocation", namespaces["xsi"]), schema_location) etree.SubElement(node0, util.nspath("Source", namespaces["csw"])).text = source etree.SubElement(node0, util.nspath("ResourceType", namespaces["csw"])).text = resourcetype if resourceformat is not None: etree.SubElement(node0, util.nspath("ResourceFormat", namespaces["csw"])).text = resourceformat if harvestinterval is not None: etree.SubElement(node0, util.nspath("HarvestInterval", namespaces["csw"])).text = harvestinterval if responsehandler is not None: etree.SubElement(node0, util.nspath("ResponseHandler", namespaces["csw"])).text = responsehandler self.request = util.xml2string(etree.tostring(node0)) self._invoke() self.results = {} if self.exceptionreport is None: val = self._exml.find(util.nspath("Acknowledgement", namespaces["csw"])) if util.testXMLValue(val) is not None: ts = val.attrib.get("timeStamp") self.timestamp = util.testXMLValue(ts, True) id = val.find(util.nspath("RequestId", namespaces["csw"])) self.id = util.testXMLValue(id) else: self._parsetransactionsummary() self._parseinsertresult()
def harvest(self, source, resourcetype, resourceformat=None, harvestinterval=None, responsehandler=None): """ Construct and process a Harvest request Parameters ---------- - source: a URI to harvest - resourcetype: namespace identifying the type of resource - resourceformat: MIME type of the resource - harvestinterval: frequency of harvesting, in ISO8601 - responsehandler: endpoint that CSW should responsd to with response """ # construct request node0 = self._setrootelement('csw:Harvest') node0.set('version', self.version) node0.set('service', self.service) node0.set(util.nspath_eval('xsi:schemaLocation', namespaces), schema_location) etree.SubElement(node0, util.nspath_eval('csw:Source', namespaces)).text = source etree.SubElement(node0, util.nspath_eval('csw:ResourceType', namespaces)).text = resourcetype if resourceformat is not None: etree.SubElement(node0, util.nspath_eval('csw:ResourceFormat', namespaces)).text = resourceformat if harvestinterval is not None: etree.SubElement(node0, util.nspath_eval('csw:HarvestInterval', namespaces)).text = harvestinterval if responsehandler is not None: etree.SubElement(node0, util.nspath_eval('csw:ResponseHandler', namespaces)).text = responsehandler self.request = util.xml2string(etree.tostring(node0)) self._invoke() self.results = {} if self.exceptionreport is None: val = self._exml.find(util.nspath_eval('csw:Acknowledgement', namespaces)) if util.testXMLValue(val) is not None: ts = val.attrib.get('timeStamp') self.timestamp = util.testXMLValue(ts, True) id = val.find(util.nspath_eval('csw:RequestId', namespaces)) self.id = util.testXMLValue(id) else: self._parsetransactionsummary() self._parseinsertresult()
def getdomain(self, dname, dtype='parameter'): """ Construct and process a GetDomain request Parameters ---------- - dname: the value of the Parameter or Property to query - dtype: whether to query a parameter (parameter) or property (property) """ # construct request dtypename = 'ParameterName' nsmap = { 'csw' : ns.get_namespace('csw'), 'xsi' : ns.get_namespace('xsi'), } node0 = setrootelement('csw:GetDomain', nsmap) node0.set('service', self.service) node0.set('version', self.version) node0.set(nsp('xsi:schemaLocation'), schema_location) if dtype == 'property': dtypename = 'PropertyName' etree.SubElement(node0, nsp('csw:%s' % dtypename)).text = dname self.request = xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: self.results = {} val = self._exml.find(nsp('csw:DomainValues')).attrib.get('type') self.results['type'] = testXMLValue(val, True) val = self._exml.find(nsp('csw:DomainValues/csw:%s' % dtypename)) self.results[dtype] = testXMLValue(val) # get the list of values associated with the Domain self.results['values'] = [] for f in self._exml.findall(nsp('csw:DomainValues/csw:ListOfValues/csw:Value')): self.results['values'].append(testXMLValue(f))
def harvest(self, source, resourcetype, resourceformat=None, harvestinterval=None, responsehandler=None): """ Construct and process a Harvest request Parameters ---------- - source: a URI to harvest - resourcetype: namespace identifying the type of resource - resourceformat: MIME type of the resource - harvestinterval: frequency of harvesting, in ISO8601 - responsehandler: endpoint that CSW should responsd to with response """ # construct request node0 = setrootelement('csw:Harvest') node0.set('version', self.version) node0.set('service', self.service) node0.set(nsp('xsi:schemaLocation'), schema_location) etree.SubElement(node0, nsp('csw:Source')).text = source etree.SubElement(node0, nsp('csw:ResourceType')).text = resourcetype if resourceformat is not None: etree.SubElement(node0, nsp('csw:ResourceFormat')).text = resourceformat if harvestinterval is not None: etree.SubElement(node0, nsp('csw:HarvestInterval')).text = harvestinterval if responsehandler is not None: etree.SubElement(node0, nsp('csw:ResponseHandler')).text = responsehandler self.request = xml2string(etree.tostring(node0)) self._invoke() self.results = {} if self.exceptionreport is None: val = self._exml.find(nsp('csw:Acknowledgement')) if testXMLValue(val) is not None: ts = val.attrib.get('timeStamp') self.timestamp = testXMLValue(ts, True) id = val.find(nsp('csw:RequestId')) self.id = testXMLValue(id) else: self._parsetransactionsummary() self._parseinsertresult()
def getdomain(self, dname, dtype="parameter"): """ Construct and process a GetDomain request Parameters ---------- - dname: the value of the Parameter or Property to query - dtype: whether to query a parameter (parameter) or property (property) """ # construct request dtypename = "ParameterName" node0 = etree.Element(util.nspath("GetDomain", namespaces["csw"])) node0.set("service", self.service) node0.set("version", self.version) node0.set(util.nspath("schemaLocation", namespaces["xsi"]), schema_location) if dtype == "property": dtypename = "PropertyName" etree.SubElement(node0, util.nspath(dtypename, namespaces["csw"])).text = dname self.request = util.xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: self.results = {} val = self._exml.find(util.nspath("DomainValues", namespaces["csw"])).attrib.get("type") self.results["type"] = util.testXMLValue(val, True) val = self._exml.find(util.nspath("DomainValues/" + dtypename, namespaces["csw"])) self.results[dtype] = util.testXMLValue(val) # get the list of values associated with the Domain self.results["values"] = [] for f in self._exml.findall(util.nspath("DomainValues/ListOfValues/Value", namespaces["csw"])): self.results["values"].append(util.testXMLValue(f))
def getrecordbyid(self, id=[], esn='full', outputschema=namespaces['csw'], format=outputformat): """ Construct and process a GetRecordById request Parameters ---------- - id: the list of Ids - esn: the ElementSetName 'full', 'brief' or 'summary' (default is 'full') - outputschema: the outputSchema (default is 'http://www.opengis.net/cat/csw/2.0.2') - format: the outputFormat (default is 'application/xml') """ # construct request node0 = etree.Element(util.nspath('GetRecordById', namespaces['csw'])) node0.set('outputSchema', outputschema) node0.set('outputFormat', format) node0.set('version', self.version) node0.set('service', self.service) node0.set(util.nspath('schemaLocation', namespaces['xsi']), schema_location) for i in id: etree.SubElement(node0, util.nspath('Id', namespaces['csw'])).text = i etree.SubElement(node0, util.nspath('ElementSetName', namespaces['csw'])).text = esn self.request = util.xml2string(etree.tostring(node0)) # invoke self.response = util.http_post(self.url, self.request, self.lang) # parse result self._records = etree.parse(StringIO.StringIO(self.response)) # check for exceptions self._isexception(self._records, self.owscommon.namespace) if self.exceptionreport is None: self.records = {} self._parserecords(outputschema, esn)
def describerecord(self, typename='csw:Record', format=outputformat): """ Construct and process DescribeRecord request Parameters ---------- - typename: the typename to describe (default is 'csw:Record') - format: the outputFormat (default is 'application/xml') """ # construct request node0 = self._setrootelement('csw:DescribeRecord') node0.set('service', self.service) node0.set('version', self.version) node0.set('outputFormat', format) node0.set('schemaLanguage', namespaces['xs2']) node0.set(util.nspath_eval('xsi:schemaLocation', namespaces), schema_location) etree.SubElement(node0, util.nspath_eval('csw:TypeName', namespaces)).text = typename self.request = util.xml2string(etree.tostring(node0)) self._invoke()
def _invoke(self): # do HTTP request if isinstance(self.request, basestring): # GET KVP self.response = urlopen(self.request, timeout=self.timeout).read() else: self.request = cleanup_namespaces(self.request) self.request = util.xml2string(etree.tostring(self.request)) self.response = util.http_post(self.url, self.request, self.lang, self.timeout) # parse result see if it's XML self._exml = etree.parse(StringIO.StringIO(self.response)) # it's XML. Attempt to decipher whether the XML response is CSW-ish """ valid_xpaths = [ util.nspath_eval('ows:ExceptionReport', namespaces), util.nspath_eval('csw:Capabilities', namespaces), util.nspath_eval('csw:DescribeRecordResponse', namespaces), util.nspath_eval('csw:GetDomainResponse', namespaces), util.nspath_eval('csw:GetRecordsResponse', namespaces), util.nspath_eval('csw:GetRecordByIdResponse', namespaces), util.nspath_eval('csw:HarvestResponse', namespaces), util.nspath_eval('csw:TransactionResponse', namespaces) ] if self._exml.getroot().tag not in valid_xpaths: raise RuntimeError, 'Document is XML, but not CSW-ish' # check if it's an OGC Exception val = self._exml.find(util.nspath_eval('ows:Exception', namespaces)) if val is not None: raise ows.ExceptionReport(self._exml, self.owscommon.namespace) else: self.exceptionreport = None
def describerecord(self, typename="csw:Record", format=outputformat): """ Construct and process DescribeRecord request Parameters ---------- - typename: the typename to describe (default is 'csw:Record') - format: the outputFormat (default is 'application/xml') """ # construct request node0 = etree.Element(util.nspath("DescribeRecord", namespaces["csw"])) node0.set("service", self.service) node0.set("version", self.version) node0.set("outputFormat", format) node0.set("schemaLanguage", namespaces["xs2"]) node0.set(util.nspath("schemaLocation", namespaces["xsi"]), schema_location) etree.SubElement(node0, util.nspath("TypeName", namespaces["csw"])).text = typename self.request = util.xml2string(etree.tostring(node0)) self._invoke()
def transaction(self, ttype=None, typename='csw:Record', record=None, propertyname=None, propertyvalue=None, bbox=None, keywords=[], cql=None): """ Construct and process a Transaction request Parameters ---------- - ttype: the type of transaction 'insert, 'update', 'delete' - typename: the typename to describe (default is 'csw:Record') - record: the XML record to insert - propertyname: the RecordProperty/PropertyName to Filter against - propertyvalue: the RecordProperty Value to Filter against (for updates) - bbox: the bounding box of the spatial query in the form [minx,miny,maxx,maxy] - keywords: list of keywords - cql: common query language text. Note this overrides bbox, qtype, keywords """ # construct request node0 = etree.Element(util.nspath_eval('csw:Transaction', namespaces)) node0.set('version', self.version) node0.set('service', self.service) node0.set(util.nspath_eval('xsi:schemaLocation', namespaces), schema_location) validtransactions = ['insert', 'update', 'delete'] if ttype not in validtransactions: # invalid transaction raise RuntimeError, 'Invalid transaction \'%s\'.' % ttype node1 = etree.SubElement( node0, util.nspath_eval('csw:%s' % ttype.capitalize(), namespaces)) if ttype != 'update': node1.set('typeName', typename) if ttype == 'insert': if record is None: raise RuntimeError, 'Nothing to insert.' node1.append(etree.fromstring(record)) if ttype == 'update': if record is not None: node1.append(etree.fromstring(record)) else: if propertyname is not None and propertyvalue is not None: node2 = etree.SubElement( node1, util.nspath_eval('csw:RecordProperty', namespaces)) etree.SubElement(node2, util.nspath_eval( 'csw:Name', namespaces)).text = propertyname etree.SubElement(node2, util.nspath_eval( 'csw:Value', namespaces)).text = propertyvalue self._setconstraint(node1, qtype, propertyname, keywords, bbox, cql) if ttype == 'delete': self._setconstraint(node1, None, propertyname, keywords, bbox, cql) self.request = util.xml2string(etree.tostring(node0)) self._invoke() self.results = {} if self.exceptionreport is None: self._parsetransactionsummary() self._parseinsertresult()
def getrecords(self, qtype=None, keywords=[], typenames='csw:Record', propertyname='AnyText', bbox=None, esn='full', sortby=None, outputschema=namespaces['csw'], format=outputformat, startposition=0, maxrecords=10): """ Construct and process a GetRecords request Parameters ---------- - qtype: type of resource to query (i.e. service, dataset) - keywords: list of keywords - typenames: the typeNames to query against (default is csw:Record) - propertyname: the PropertyName to Filter against - bbox: the bounding box of the spatial query in the form [minx,miny,maxx,maxy] - esn: the ElementSetName 'full', 'brief' or 'summary' (default is 'full') - sortby: property to sort results on (default is 'dc:title') - outputschema: the outputSchema (default is 'http://www.opengis.net/cat/csw/2.0.2') - format: the outputFormat (default is 'application/xml') - startposition: requests a slice of the result set, starting at this position (default is 0) - maxrecords: the maximum number of records to return. No records are returned if 0 (default is 10) """ # construct request node0 = etree.Element(util.nspath('GetRecords', namespaces['csw'])) node0.set('outputSchema', outputschema) node0.set('outputFormat', format) node0.set('version', self.version) node0.set('resultType', 'results') node0.set('service', self.service) if startposition > 0: node0.set('startPosition', str(startposition)) node0.set('maxRecords', str(maxrecords)) node0.set(util.nspath('schemaLocation', namespaces['xsi']), schema_location) # decipher number of query parameters ( > 1 sets an 'And' Filter pcount = 0 if qtype is not None: pcount += 1 if keywords: pcount += 1 if bbox is not None: pcount += 1 node1 = etree.SubElement(node0, util.nspath('Query', namespaces['csw'])) node1.set('typeNames', typenames) etree.SubElement(node1, util.nspath('ElementSetName', namespaces['csw'])).text = esn # decipher if the query is for real if keywords or bbox is not None or qtype is not None: node2 = etree.SubElement(node1, util.nspath('Constraint', namespaces['csw'])) node2.set('version', '1.1.0') node3 = etree.SubElement(node2, util.nspath('Filter', namespaces['ogc'])) node4 = None # construct a Filter request flt = FilterRequest() if pcount > 1: # Filter should be And-ed node4 = etree.SubElement(node3, util.nspath('And', namespaces['ogc'])) # set the query type if passed # TODO: need a smarter way to figure these out if qtype is not None: if node4 is not None: flt.setpropertyisequalto(node4, 'dc:type', qtype) else: flt.setpropertyisequalto(node3, 'dc:type', qtype) # set a bbox query if passed if bbox is not None: if node4 is not None: flt.setbbox(node4, bbox) else: flt.setbbox(node3, bbox) # set a keyword query if passed if len(keywords) > 0: if len(keywords) > 1: # loop multiple keywords into an Or if node4 is not None: node5 = etree.SubElement(node4, util.nspath('Or', namespaces['ogc'])) else: node5 = etree.SubElement(node3, util.nspath('Or', namespaces['ogc'])) for i in keywords: flt.setpropertyislike(node5, propertyname, '%%%s%%' % i) else: # one keyword if node4 is not None: flt.setpropertyislike(node4, propertyname, '%%%s%%' % keywords[0]) else: flt.setpropertyislike(node3, propertyname, '%%%s%%' % keywords[0]) # set a sort if passed if sortby is not None: flt.setsortby(node1, sortby) self.request = util.xml2string(etree.tostring(node0)) # invoke self.response = util.http_post(self.url, self.request, self.lang) # parse result self._records = etree.parse(StringIO.StringIO(self.response)) # check for exceptions self._isexception(self._records, self.owscommon.namespace) if self.exceptionreport is None: self.results = {} # process search results attributes val = self._records.find(util.nspath('SearchResults', namespaces['csw'])).attrib.get('numberOfRecordsMatched') self.results['matches'] = int(util.testXMLValue(val, True)) val = self._records.find(util.nspath('SearchResults', namespaces['csw'])).attrib.get('numberOfRecordsReturned') self.results['returned'] = int(util.testXMLValue(val, True)) val = self._records.find(util.nspath('SearchResults', namespaces['csw'])).attrib.get('nextRecord') self.results['nextrecord'] = int(util.testXMLValue(val, True)) # process list of matching records self.records = {} self._parserecords(outputschema, esn)
def transaction( self, ttype=None, typename="csw:Record", record=None, propertyname=None, propertyvalue=None, bbox=None, keywords=[], cql=None, ): """ Construct and process a Transaction request Parameters ---------- - ttype: the type of transaction 'insert, 'update', 'delete' - typename: the typename to describe (default is 'csw:Record') - record: the XML record to insert - propertyname: the RecordProperty/PropertyName to Filter against - propertyvalue: the RecordProperty Value to Filter against (for updates) - bbox: the bounding box of the spatial query in the form [minx,miny,maxx,maxy] - keywords: list of keywords - cql: common query language text. Note this overrides bbox, qtype, keywords """ # construct request node0 = etree.Element(util.nspath("Transaction", namespaces["csw"])) node0.set("version", self.version) node0.set("service", self.service) node0.set(util.nspath("schemaLocation", namespaces["xsi"]), schema_location) validtransactions = ["insert", "update", "delete"] if ttype not in validtransactions: # invalid transaction raise RuntimeError, "Invalid transaction '%s'." % ttype node1 = etree.SubElement(node0, util.nspath("%s" % ttype.capitalize(), namespaces["csw"])) if ttype != "update": node1.set("typeName", typename) if ttype == "insert": if record is None: raise RuntimeError, "Nothing to insert." node1.append(etree.fromstring(record)) if ttype == "update": if record is not None: node1.append(etree.fromstring(record)) else: if propertyname is not None and propertyvalue is not None: node2 = etree.SubElement(node1, util.nspath("RecordProperty", namespaces["csw"])) etree.SubElement(node2, util.nspath("Name", namespaces["csw"])).text = propertyname etree.SubElement(node2, util.nspath("Value", namespaces["csw"])).text = propertyvalue self._setconstraint(node1, qtype, propertyname, keywords, bbox, cql) if ttype == "delete": self._setconstraint(node1, None, propertyname, keywords, bbox, cql) self.request = util.xml2string(etree.tostring(node0)) self._invoke() self.results = {} if self.exceptionreport is None: self._parsetransactionsummary() self._parseinsertresult()
def __init__(self, url, lang='en-US', version='2.0.2', timeout=10): """ Construct and process a GetCapabilities request Parameters ---------- - url: the URL of the CSW - lang: the language (default is 'en-US') - version: version (default is '2.0.2') - timeout: timeout in seconds """ self.url = url self.lang = lang self.version = version self.timeout = timeout self.service = 'CSW' self.exceptionreport = None self.owscommon = OwsCommon('1.0.0') # construct request node0 = etree.Element(util.nspath('GetCapabilities', namespaces['csw'])) node0.set('service', self.service) node0.set(util.nspath('schemaLocation', namespaces['xsi']), schema_location) tmp = etree.SubElement( node0, util.nspath('AcceptVersions', namespaces['ows'])) etree.SubElement(tmp, util.nspath('Version', namespaces['ows'])).text = self.version tmp2 = etree.SubElement( node0, util.nspath('AcceptFormats', namespaces['ows'])) etree.SubElement(tmp2, util.nspath('OutputFormat', namespaces['ows'])).text = outputformat self.request = util.xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: # ServiceIdentification val = self._exml.find( util.nspath('ServiceIdentification', namespaces['ows'])) self.identification = ServiceIdentification( val, self.owscommon.namespace) # ServiceProvider val = self._exml.find( util.nspath('ServiceProvider', namespaces['ows'])) self.provider = ServiceProvider(val, self.owscommon.namespace) # ServiceOperations metadata self.operations = [] for elem in self._exml.findall( util.nspath('OperationsMetadata/Operation', namespaces['ows'])): self.operations.append( OperationsMetadata(elem, self.owscommon.namespace)) # FilterCapabilities val = self._exml.find( util.nspath('Filter_Capabilities', namespaces['ogc'])) self.filters = FilterCapabilities(val)
def getrecords( self, qtype=None, keywords=[], typenames="csw:Record", propertyname="AnyText", bbox=None, esn="full", sortby=None, outputschema=namespaces["csw"], format=outputformat, startposition=0, maxrecords=10, cql=None, ): """ Construct and process a GetRecords request Parameters ---------- - qtype: type of resource to query (i.e. service, dataset) - keywords: list of keywords - typenames: the typeNames to query against (default is csw:Record) - propertyname: the PropertyName to Filter against - bbox: the bounding box of the spatial query in the form [minx,miny,maxx,maxy] - esn: the ElementSetName 'full', 'brief' or 'summary' (default is 'full') - sortby: property to sort results on (default is 'dc:title') - outputschema: the outputSchema (default is 'http://www.opengis.net/cat/csw/2.0.2') - format: the outputFormat (default is 'application/xml') - startposition: requests a slice of the result set, starting at this position (default is 0) - maxrecords: the maximum number of records to return. No records are returned if 0 (default is 10) - cql: common query language text. Note this overrides bbox, qtype, keywords """ # construct request node0 = etree.Element(util.nspath("GetRecords", namespaces["csw"])) node0.set("outputSchema", outputschema) node0.set("outputFormat", format) node0.set("version", self.version) node0.set("resultType", "results") node0.set("service", self.service) if startposition > 0: node0.set("startPosition", str(startposition)) node0.set("maxRecords", str(maxrecords)) node0.set(util.nspath("schemaLocation", namespaces["xsi"]), schema_location) node1 = etree.SubElement(node0, util.nspath("Query", namespaces["csw"])) node1.set("typeNames", typenames) etree.SubElement(node1, util.nspath("ElementSetName", namespaces["csw"])).text = esn self._setconstraint(node1, qtype, propertyname, keywords, bbox, cql) if sortby is not None: setsortby(node1, sortby) self.request = util.xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: self.results = {} # process search results attributes val = self._exml.find(util.nspath("SearchResults", namespaces["csw"])).attrib.get("numberOfRecordsMatched") self.results["matches"] = int(util.testXMLValue(val, True)) val = self._exml.find(util.nspath("SearchResults", namespaces["csw"])).attrib.get("numberOfRecordsReturned") self.results["returned"] = int(util.testXMLValue(val, True)) val = self._exml.find(util.nspath("SearchResults", namespaces["csw"])).attrib.get("nextRecord") nextrecord = util.testXMLValue(val, True) self.results["nextrecord"] = int(nextrecord) if nextrecord is not None else None # process list of matching records self.records = {} self._parserecords(outputschema, esn)
def getrecords(self, qtype=None, keywords=[], typenames='csw:Record', propertyname='csw:AnyText', bbox=None, esn='summary', sortby=None, outputschema=namespaces['csw'], format=outputformat, startposition=0, maxrecords=10, cql=None, xml=None, resulttype='results'): """ Construct and process a GetRecords request Parameters ---------- - qtype: type of resource to query (i.e. service, dataset) - keywords: list of keywords - typenames: the typeNames to query against (default is csw:Record) - propertyname: the PropertyName to Filter against - bbox: the bounding box of the spatial query in the form [minx,miny,maxx,maxy] - esn: the ElementSetName 'full', 'brief' or 'summary' (default is 'summary') - sortby: property to sort results on (default is 'dc:title') - outputschema: the outputSchema (default is 'http://www.opengis.net/cat/csw/2.0.2') - format: the outputFormat (default is 'application/xml') - startposition: requests a slice of the result set, starting at this position (default is 0) - maxrecords: the maximum number of records to return. No records are returned if 0 (default is 10) - cql: common query language text. Note this overrides bbox, qtype, keywords - xml: raw XML request. Note this overrides all other options - resulttype: the resultType 'hits', 'results', 'validate' (default is 'results') """ if xml is not None: self.request = xml e=etree.fromstring(xml) val = e.find(util.nspath_eval('csw:Query/csw:ElementSetName', namespaces)) if val is not None: esn = util.testXMLValue(val) else: # construct request node0 = self._setrootelement('csw:GetRecords') if etree.__name__ != 'lxml.etree': # apply nsmap manually node0.set('xmlns:ows', namespaces['ows']) node0.set('xmlns:gmd', namespaces['gmd']) node0.set('xmlns:dif', namespaces['dif']) node0.set('xmlns:fgdc', namespaces['fgdc']) node0.set('outputSchema', outputschema) node0.set('outputFormat', format) node0.set('version', self.version) node0.set('resultType', resulttype) node0.set('service', self.service) if startposition > 0: node0.set('startPosition', str(startposition)) node0.set('maxRecords', str(maxrecords)) node0.set(util.nspath_eval('xsi:schemaLocation', namespaces), schema_location) node1 = etree.SubElement(node0, util.nspath_eval('csw:Query', namespaces)) node1.set('typeNames', typenames) etree.SubElement(node1, util.nspath_eval('csw:ElementSetName', namespaces)).text = esn self._setconstraint(node1, qtype, propertyname, keywords, bbox, cql) if sortby is not None: fes.setsortby(node1, sortby) self.request = util.xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: self.results = {} # process search results attributes val = self._exml.find(util.nspath_eval('csw:SearchResults', namespaces)).attrib.get('numberOfRecordsMatched') self.results['matches'] = int(util.testXMLValue(val, True)) val = self._exml.find(util.nspath_eval('csw:SearchResults', namespaces)).attrib.get('numberOfRecordsReturned') self.results['returned'] = int(util.testXMLValue(val, True)) val = self._exml.find(util.nspath_eval('csw:SearchResults', namespaces)).attrib.get('nextRecord') self.results['nextrecord'] = int(util.testXMLValue(val, True)) # process list of matching records self.records = {} self._parserecords(outputschema, esn)
def getrecords(self, qtype=None, keywords=[], typenames='csw:Record', propertyname='csw:AnyText', bbox=None, esn='full', sortby=None, outputschema=namespaces['csw'], format=outputformat, startposition=0, maxrecords=10, cql=None, xml=None): """ Construct and process a GetRecords request Parameters ---------- - qtype: type of resource to query (i.e. service, dataset) - keywords: list of keywords - typenames: the typeNames to query against (default is csw:Record) - propertyname: the PropertyName to Filter against - bbox: the bounding box of the spatial query in the form [minx,miny,maxx,maxy] - esn: the ElementSetName 'full', 'brief' or 'summary' (default is 'full') - sortby: property to sort results on (default is 'dc:title') - outputschema: the outputSchema (default is 'http://www.opengis.net/cat/csw/2.0.2') - format: the outputFormat (default is 'application/xml') - startposition: requests a slice of the result set, starting at this position (default is 0) - maxrecords: the maximum number of records to return. No records are returned if 0 (default is 10) - cql: common query language text. Note this overrides bbox, qtype, keywords - xml: raw XML request. Note this overrides all other options """ if xml is not None: self.request = xml e = etree.fromstring(xml) val = e.find( util.nspath_eval('csw:Query/csw:ElementSetName', namespaces)) if val is not None: esn = util.testXMLValue(val) else: # construct request node0 = etree.Element( util.nspath_eval('csw:GetRecords', namespaces)) node0.set('xmlns:ows', namespaces['ows']) node0.set('outputSchema', outputschema) node0.set('outputFormat', format) node0.set('version', self.version) node0.set('resultType', 'results') node0.set('service', self.service) if startposition > 0: node0.set('startPosition', str(startposition)) node0.set('maxRecords', str(maxrecords)) node0.set(util.nspath_eval('xsi:schemaLocation', namespaces), schema_location) node1 = etree.SubElement(node0, util.nspath_eval('csw:Query', namespaces)) node1.set('typeNames', typenames) etree.SubElement( node1, util.nspath_eval('csw:ElementSetName', namespaces)).text = esn self._setconstraint(node1, qtype, propertyname, keywords, bbox, cql) if sortby is not None: setsortby(node1, sortby) self.request = util.xml2string(etree.tostring(node0)) self._invoke() if self.exceptionreport is None: self.results = {} # process search results attributes val = self._exml.find( util.nspath_eval( 'csw:SearchResults', namespaces)).attrib.get('numberOfRecordsMatched') self.results['matches'] = int(util.testXMLValue(val, True)) val = self._exml.find( util.nspath_eval( 'csw:SearchResults', namespaces)).attrib.get('numberOfRecordsReturned') self.results['returned'] = int(util.testXMLValue(val, True)) val = self._exml.find( util.nspath_eval('csw:SearchResults', namespaces)).attrib.get('nextRecord') self.results['nextrecord'] = int(util.testXMLValue(val, True)) # process list of matching records self.records = {} self._parserecords(outputschema, esn)
def transaction(self, ttype=None, typename='csw:Record', record=None, propertyname=None, propertyvalue=None, bbox=None, keywords=[], cql=None, identifier=None): """ Construct and process a Transaction request Parameters ---------- - ttype: the type of transaction 'insert, 'update', 'delete' - typename: the typename to describe (default is 'csw:Record') - record: the XML record to insert - propertyname: the RecordProperty/PropertyName to Filter against - propertyvalue: the RecordProperty Value to Filter against (for updates) - bbox: the bounding box of the spatial query in the form [minx,miny,maxx,maxy] - keywords: list of keywords - cql: common query language text. Note this overrides bbox, qtype, keywords - identifier: record identifier. Note this overrides bbox, qtype, keywords, cql """ # construct request node0 = self._setrootelement('csw:Transaction') node0.set('version', self.version) node0.set('service', self.service) node0.set(util.nspath_eval('xsi:schemaLocation', namespaces), schema_location) validtransactions = ['insert', 'update', 'delete'] if ttype not in validtransactions: # invalid transaction raise RuntimeError, 'Invalid transaction \'%s\'.' % ttype node1 = etree.SubElement(node0, util.nspath_eval('csw:%s' % ttype.capitalize(), namespaces)) if ttype != 'update': node1.set('typeName', typename) if ttype == 'insert': if record is None: raise RuntimeError, 'Nothing to insert.' node1.append(etree.fromstring(record)) if ttype == 'update': if record is not None: node1.append(etree.fromstring(record)) else: if propertyname is not None and propertyvalue is not None: node2 = etree.SubElement(node1, util.nspath_eval('csw:RecordProperty', namespaces)) etree.SubElement(node2, util.nspath_eval('csw:Name', namespaces)).text = propertyname etree.SubElement(node2, util.nspath_eval('csw:Value', namespaces)).text = propertyvalue self._setconstraint(node1, qtype, propertyname, keywords, bbox, cql, identifier) if ttype == 'delete': self._setconstraint(node1, None, propertyname, keywords, bbox, cql, identifier) self.request = util.xml2string(etree.tostring(node0)) self._invoke() self.results = {} if self.exceptionreport is None: self._parsetransactionsummary() self._parseinsertresult()