From 80c666821ab18f6a7d6fa45740408697e717f895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Cantu=C3=A1ria?= Date: Tue, 19 Mar 2019 11:37:52 -0300 Subject: [PATCH] Resolve problema do batch_size na request (#2624) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige verificação de existencia de chave no dicionário --- sapl/lexml/OAIServer.py | 4 ++-- sapl/lexml/views.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sapl/lexml/OAIServer.py b/sapl/lexml/OAIServer.py index 2a5745d67..643d17f9e 100644 --- a/sapl/lexml/OAIServer.py +++ b/sapl/lexml/OAIServer.py @@ -26,7 +26,7 @@ class OAILEXML: def __call__(self, element, metadata): data = metadata.record - if data['metadata']: + if data.get('metadata'): value = etree.XML(data['metadata']) element.append(value) @@ -55,7 +55,7 @@ class OAIServer: granularity='YYYY-MM-DDThh:mm:ssZ', compression=['identity'], toolkit_description=False) - if self.config['descricao']: + if self.config.get('descricao'): result.add_description(self.config['descricao']) return result diff --git a/sapl/lexml/views.py b/sapl/lexml/views.py index 46945aa2c..92fee8310 100644 --- a/sapl/lexml/views.py +++ b/sapl/lexml/views.py @@ -18,10 +18,15 @@ class LexmlProvedorCrud(Crud): class DetailView(Crud.DetailView): layout_key = 'LexmlProvedorDetail' + def lexml_request(request): + request_dict = request.GET.copy() + if request_dict.get('batch_size'): + del request_dict['batch_size'] + config = get_config(request.get_raw_uri(), int(request.GET.get('batch_size', '10'))) oai_server = OAIServerFactory(config) - r = oai_server.handleRequest(request.GET) + r = oai_server.handleRequest(request_dict) response = r.decode('UTF-8') return HttpResponse(response, content_type='text/xml')