[PATCH 1 of 2 oaipmh] Use Pyramid route URL to export baseURL element in Identify response

Denis Laxalde denis.laxalde at logilab.fr
Mon Mar 20 15:15:41 CET 2017


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1490017812 -3600
#      Mon Mar 20 14:50:12 2017 +0100
# Node ID 0c1aa21839078168694d70d3b220e88c385db9f3
# Parent  693a9fa19c80c7497c4fb0a161da689591b028d8
Use Pyramid route URL to export baseURL element in Identify response

Using _cw.build_url() is wrong since the we have a Pyramid route not a
CubicWeb URL rewrite rule.

diff --git a/test/test_oaipmh.py b/test/test_oaipmh.py
--- a/test/test_oaipmh.py
+++ b/test/test_oaipmh.py
@@ -345,7 +345,7 @@ class OAIPMHViewsTC(PyramidCWTest, OAITe
         with self.admin_access.web_request() as req:
             result = self.oai_request(req, verb='Identify')
         self.assertIn('<repositoryName>unset title</repositoryName>', result)
-        self.assertIn('<baseURL>https://localhost.local/oai</baseURL>', result)
+        self.assertIn('<baseURL>https://localhost:80/oai</baseURL>', result)
         self.assertIn('<protocolVersion>2.0</protocolVersion>', result)
         self.assertIn('<adminEmail>oai-admin at example.org</adminEmail>', result)
         self.assertIn('<deletedRecord>no', result)
diff --git a/views.py b/views.py
--- a/views.py
+++ b/views.py
@@ -391,8 +391,7 @@ class OAIIdentifyView(OAIView):
     def verb_content(self):
         oai = self._cw.vreg['components'].select('oai', self._cw)
         yield E('repositoryName', self._cw.property_value('ui.site-title'))
-        # XXX Should match the URL rewrite rule.
-        yield E('baseURL', self._cw.build_url('oai'))
+        yield E('baseURL', self.request.route_url('oai'))
         yield E('protocolVersion', '2.0')
         try:
             admin_email = self._cw.vreg.config['admin-email']



More information about the saem-devel mailing list