def handleVerb(self, verb, kw): if 'resumptionToken' in kw: kw, cursor = decodeResumptionToken( kw['resumptionToken']) kw['cursor'] = cursor method = common.getMethodForVerb(self._server, verb) # now handle resumption system if verb in ['ListSets', 'ListIdentifiers', 'ListRecords']: kw = kw.copy() cursor = kw.get('cursor', None) if cursor is None: kw['cursor'] = cursor = 0 # we request 1 beyond the batch size, so that # if we retrieve <= batch_size items, we know we # don't need to output another resumption token kw['batch_size'] = self._batch_size + 1 result = method(**kw) result = list(result) if len(result) > self._batch_size: # more results are expected, so encode resumption token resumptionToken = encodeResumptionToken( kw, cursor + self._batch_size) # we also want to result only the batch_size, so pop the # last one result.pop() else: # no more results are expected resumptionToken = None return result, resumptionToken return method(**kw)
def handleVerb(self, verb, kw): # do original query method = common.getMethodForVerb(self._server, verb) # if we're handling a resumption token if 'resumptionToken' in kw: kw, cursor = decodeResumptionToken( kw['resumptionToken']) end_batch = cursor + self._batch_size # do query again with original parameters result = method(**kw) # XXX defeat laziness of any generators.. result = list(result) if end_batch < len(result): resumptionToken = encodeResumptionToken( kw, end_batch) else: resumptionToken = None return result[cursor:end_batch], resumptionToken # we're not handling resumption token, so do request result = method(**kw) # now handle resumption system if verb in ['ListSets', 'ListIdentifiers', 'ListRecords']: # XXX defeat the laziness effect of any generators.. result = list(result) end_batch = self._batch_size if end_batch < len(result): resumptionToken = encodeResumptionToken( kw, end_batch) else: resumptionToken = None return result[0:end_batch], resumptionToken return result
def handleVerb(self, verb, kw): # fetch the method for the verb method = getMethodForVerb(self._server, verb) if verb in ['ListSets', 'ListIdentifiers', 'ListRecords']: batch_size = self._batch_size # check for resumption token if 'resumptionToken' in kw: kw, cursor = decodeResumptionToken(kw['resumptionToken']) else: cursor = 0 kw['cursor'] = cursor end_batch = cursor + batch_size # Fetch only self._batch_size results # Request 1 more so that we know whether resumptionToken is needed # we'll trim this off later kw['batch_size'] = batch_size + 1 result = method(**kw) del kw['cursor'], kw['batch_size'] # XXX defeat the laziness effect of any generators.. result = list(result) if len(result) > batch_size: # we need a resumption token resumptionToken = encodeResumptionToken(kw, end_batch) result.pop(-1) else: resumptionToken = None return result, resumptionToken else: result = method(**kw) return result
def handleVerb(self, verb, kw): # fetch the method for the verb method = getMethodForVerb(self._server, verb) if verb in ['ListSets', 'ListIdentifiers', 'ListRecords']: batch_size = self._batch_size # check for resumption token if 'resumptionToken' in kw: kw, cursor = decodeResumptionToken(kw['resumptionToken']) else: cursor = 0 kw['cursor'] = cursor end_batch = cursor + batch_size # fetch only self._batch_size results kw['batch_size'] = batch_size + 1 # request 1 more so that we know whether resumptionToken is needed we'll trim this off later result = method(**kw) del kw['cursor'], kw['batch_size'] # XXX defeat the laziness effect of any generators.. result = list(result) if len(result) > batch_size: # we need a resumption token resumptionToken = encodeResumptionToken(kw, end_batch) result.pop(-1) else: resumptionToken = None return result, resumptionToken else: result = method(**kw) return result
def handleVerb(self, verb, kw): method = common.getMethodForVerb(self._tree_server, verb) root = method(**kw).getroot() root.addprevious(etree.PI('xml-stylesheet', 'type="text/xsl" href="/oai2.xsl"')) return etree.tostring(root.getroottree(), encoding='UTF-8', xml_declaration=True, pretty_print=True)
def handleVerb(self, verb, kw): method = common.getMethodForVerb(self._tree_server, verb) XmlOriginal = etree.tostring(method(**kw).getroot(), encoding='UTF-8', xml_declaration=True, pretty_print=True) XmlSobreescrito= XmlOriginal.replace('xmlns:dc="http://purl.org/dc/elements/1.1/"', 'xmlns:dc="http://purl.org/dc/elements/1.1/" ' 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') print etree.tostring(method(**kw).getroot(), encoding='UTF-8', xml_declaration=True, pretty_print=True) return XmlSobreescrito
def handleVerb(self, verb, kw): method = common.getMethodForVerb(self._tree_server, verb) return etree.tostring(method(**kw).getroot(), encoding='UTF-8', xml_declaration=True, pretty_print=True)