Merge lp:~sinzui/launchpad/rdf-links-1 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Leonard Richardson
Approved revision: no longer in the source branch.
Merged at revision: 11651
Proposed branch: lp:~sinzui/launchpad/rdf-links-1
Merge into: lp:launchpad
Diff against target: 205 lines (+80/-24)
8 files modified
lib/canonical/launchpad/browser/launchpad.py (+0/-6)
lib/canonical/launchpad/configure.zcml (+0/-13)
lib/lp/registry/browser/__init__.py (+18/-1)
lib/lp/registry/browser/configure.zcml (+17/-0)
lib/lp/registry/browser/tests/test_rdf.py (+35/-0)
lib/lp/registry/rdfspec/launchpad.owl (+1/-1)
lib/lp/registry/templates/rdf-index.pt (+6/-3)
lib/lp/services/mime.py (+3/-0)
To merge this branch: bzr merge lp:~sinzui/launchpad/rdf-links-1
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Review via email: mp+36865@code.launchpad.net

Description of the change

This is my branch to fix the /rdf explanation and OWL.

    lp:~sinzui/launchpad/rdf-links-1
    Diff size: 206
    Launchpad bug:
        https://bugs.launchpad.net/bugs/6405
    Test command: ./bin/test -vv -t TestRootRDF
    Pre-implementation: no one
    Target release: 10.10

Fix the /rdf explanation and OWL
---------------------------------

/rdf states Launchpad provides exports of project metadata. This is not
exactly true. Launchpad provides RDF description of projects and people.

The link the the OWL was broken in 2006.

Rules
-----

    * Moved the view, template, and OWL to lp.registry.
    * Add an ExportedFolder to support the OWL file.
    * Revised the description of Launchpad's RDF.

QA
--

    * Visit https://edge.launchpad.net/rdf
    * Verify the page explains what has RDF and how it can be retrieved.
    * Follow the link to the OWL file.
    * Verify the file downloads (or displays in your browser if it supports
      application/rdf+xml)

Lint
----

Linting changed files:
  lib/canonical/launchpad/configure.zcml
  lib/canonical/launchpad/browser/launchpad.py
  lib/lp/registry/browser/__init__.py
  lib/lp/registry/browser/configure.zcml
  lib/lp/registry/browser/tests/test_rdf.py
  lib/lp/registry/rdfspec/launchpad.owl
  lib/lp/registry/templates/rdf-index.pt
  lib/lp/services/mime.py

Test
----

Added a test to verify the view and the OWL file.
    * lib/lp/registry/browser/tests/test_rdf.py

Implementation
--------------

Moved the RDFIndexView to lp.registry and define RDFFolder to replace the
broken resourceDirectory.
    * lib/canonical/launchpad/configure.zcml
    * lib/canonical/launchpad/browser/launchpad.py
    * lib/lp/registry/browser/configure.zcml
    * lib/lp/registry/browser/__init__.py

Revised the namespace to match the exported folder and added mimetype
support for OWL.
    * lib/lp/registry/rdfspec/launchpad.owl
    * lib/lp/services/mime.py

Revised the text of the page.
    * lib/lp/registry/templates/rdf-index.pt

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/browser/launchpad.py'
2--- lib/canonical/launchpad/browser/launchpad.py 2010-09-24 00:45:05 +0000
3+++ lib/canonical/launchpad/browser/launchpad.py 2010-09-28 19:22:43 +0000
4@@ -17,7 +17,6 @@
5 'LoginStatus',
6 'MaintenanceMessage',
7 'NavigationMenuTabs',
8- 'RDFIndexView',
9 'SoftTimeoutView',
10 'get_launchpad_views',
11 ]
12@@ -927,8 +926,3 @@
13
14 def __call__(self):
15 raise NotFound(self.context, self.__name__)
16-
17-
18-class RDFIndexView(LaunchpadView):
19- """View for /rdf page."""
20- page_title = label = "Launchpad RDF"
21
22=== modified file 'lib/canonical/launchpad/configure.zcml'
23--- lib/canonical/launchpad/configure.zcml 2010-09-12 15:15:16 +0000
24+++ lib/canonical/launchpad/configure.zcml 2010-09-28 19:22:43 +0000
25@@ -75,19 +75,6 @@
26 parent_utility="canonical.launchpad.interfaces.ILaunchpadRoot"
27 />
28
29- <!-- RDF downloadable documents -->
30- <browser:page
31- for="canonical.launchpad.interfaces.ILaunchpadRoot"
32- class="canonical.launchpad.browser.launchpad.RDFIndexView"
33- name="rdf"
34- template="templates/rdf-index.pt"
35- permission="zope.Public"
36- />
37-
38- <browser:resourceDirectory
39- name="rdf"
40- directory="rdfspec" />
41-
42 <i18n:registerTranslations directory="locales" />
43
44 <browser:navigation
45
46=== modified file 'lib/lp/registry/browser/__init__.py'
47--- lib/lp/registry/browser/__init__.py 2010-09-23 16:15:34 +0000
48+++ lib/lp/registry/browser/__init__.py 2010-09-28 19:22:43 +0000
49@@ -9,6 +9,7 @@
50 'BaseRdfView',
51 'get_status_counts',
52 'MilestoneOverlayMixin',
53+ 'RDFIndexView',
54 'RegistryEditFormView',
55 'RegistryDeleteViewMixin',
56 'StatusCount',
57@@ -16,6 +17,7 @@
58
59
60 from operator import attrgetter
61+import os
62
63 from storm.store import Store
64 from zope.component import getUtility
65@@ -25,7 +27,11 @@
66 action,
67 LaunchpadEditFormView,
68 )
69-from canonical.launchpad.webapp.publisher import canonical_url
70+from canonical.launchpad.webapp.publisher import (
71+ canonical_url,
72+ LaunchpadView,
73+ )
74+from canonical.lazr import ExportedFolder
75 from lp.bugs.interfaces.bugtask import (
76 BugTaskSearchParams,
77 IBugTaskSet,
78@@ -284,3 +290,14 @@
79 unicodedata = self.template()
80 encodeddata = unicodedata.encode('utf-8')
81 return encodeddata
82+
83+
84+class RDFIndexView(LaunchpadView):
85+ """View for /rdf page."""
86+ page_title = label = "Launchpad RDF"
87+
88+
89+class RDFFolder(ExportedFolder):
90+ """Export the Launchpad RDF schemas."""
91+ folder = os.path.join(
92+ os.path.dirname(os.path.realpath(__file__)), '../rdfspec/')
93
94=== modified file 'lib/lp/registry/browser/configure.zcml'
95--- lib/lp/registry/browser/configure.zcml 2010-09-21 03:30:43 +0000
96+++ lib/lp/registry/browser/configure.zcml 2010-09-28 19:22:43 +0000
97@@ -8,6 +8,23 @@
98 xmlns:i18n="http://namespaces.zope.org/i18n"
99 xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc"
100 i18n_domain="launchpad">
101+ <!-- RDF downloadable documents -->
102+ <browser:page
103+ for="canonical.launchpad.interfaces.ILaunchpadRoot"
104+ class="lp.registry.browser.RDFIndexView"
105+ name="rdf"
106+ template="../templates/rdf-index.pt"
107+ permission="zope.Public"
108+ />
109+
110+ <browser:page
111+ for="canonical.launchpad.webapp.interfaces.ILaunchpadApplication"
112+ name="rdf-spec"
113+ class="lp.registry.browser.RDFFolder"
114+ attribute="__call__"
115+ permission="zope.Public"
116+ />
117+
118 <browser:page
119 for="lp.registry.interfaces.product.IProduct"
120 name="+voucher-purchase-instructions"
121
122=== added file 'lib/lp/registry/browser/tests/test_rdf.py'
123--- lib/lp/registry/browser/tests/test_rdf.py 1970-01-01 00:00:00 +0000
124+++ lib/lp/registry/browser/tests/test_rdf.py 2010-09-28 19:22:43 +0000
125@@ -0,0 +1,35 @@
126+# Copyright 2010 Canonical Ltd. This software is licensed under the
127+# GNU Affero General Public License version 3 (see the file LICENSE).
128+
129+"""Tests for RDF main views."""
130+
131+__metaclass__ = type
132+
133+from zope.component import getUtility
134+from canonical.launchpad.webapp.interfaces import (
135+ ILaunchpadApplication,
136+ ILaunchpadRoot,
137+ )
138+from canonical.testing.layers import DatabaseFunctionalLayer
139+from lp.testing import TestCaseWithFactory
140+from lp.testing.views import create_view
141+
142+
143+class TestRootRDF(TestCaseWithFactory):
144+
145+ layer = DatabaseFunctionalLayer
146+
147+ def test_root_rdf(self):
148+ root = getUtility(ILaunchpadRoot)
149+ view = create_view(root, name='rdf')
150+ self.assertEqual('Launchpad RDF', view.page_title)
151+
152+ def test_launchpad_owl(self):
153+ app = getUtility(ILaunchpadApplication)
154+ view = create_view(app, name='rdf-spec')
155+ owl = view.publishTraverse(view.request, 'launchpad.owl')
156+ entity = 'ENTITY launchpad "https://launchpad.net/rdf-spec/launchpad#'
157+ self.assertTrue(entity in owl())
158+ self.assertEqual(
159+ 'application/rdf+xml',
160+ owl.request.response.getHeader('content-type'))
161
162=== renamed directory 'lib/canonical/launchpad/rdfspec' => 'lib/lp/registry/rdfspec'
163=== modified file 'lib/lp/registry/rdfspec/launchpad.owl'
164--- lib/canonical/launchpad/rdfspec/launchpad.owl 2009-06-30 21:06:27 +0000
165+++ lib/lp/registry/rdfspec/launchpad.owl 2010-09-28 19:22:43 +0000
166@@ -5,7 +5,7 @@
167 <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">
168 <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
169 <!ENTITY owl "http://www.w3.org/2002/07/owl#">
170-<!ENTITY launchpad "https://launchpad.net/rdf/launchpad#">
171+<!ENTITY launchpad "https://launchpad.net/rdf-spec/launchpad#">
172 <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
173 <!ENTITY doaml "http://ns.balbinus.net/doaml#">
174 ]>
175
176=== renamed file 'lib/canonical/launchpad/templates/rdf-index.pt' => 'lib/lp/registry/templates/rdf-index.pt'
177--- lib/canonical/launchpad/templates/rdf-index.pt 2009-09-18 14:12:06 +0000
178+++ lib/lp/registry/templates/rdf-index.pt 2010-09-28 19:22:43 +0000
179@@ -11,9 +11,12 @@
180 <div metal:fill-slot="main">
181 <p>
182 Launchpad provides <abbr title="Resource Description Framework">RDF</abbr>
183- exports of project, project, branch, and release metadata,
184- using <a href="/@@/rdf/launchpad.owl">an ontology defined in
185- <abbr title="Web Ontology Language">OWL</abbr></a>.
186+ descriptions of project groups, projects, series, releases, users, and
187+ teams using <a href="/rdf-spec/launchpad.owl">an ontology defined in
188+ <abbr title="Web Ontology Language">OWL</abbr></a>. Links to download
189+ the RDF metadata are located on each resource's main page, except
190+ for users and teams. All resources that have an RDF description provide
191+ a meta link to the data in the page's head content.
192 </p>
193 </div>
194
195
196=== modified file 'lib/lp/services/mime.py'
197--- lib/lp/services/mime.py 2010-04-28 20:18:48 +0000
198+++ lib/lp/services/mime.py 2010-09-28 19:22:43 +0000
199@@ -32,3 +32,6 @@
200 # of type text/x-diff inline, so making this text/plain because
201 # viewing .debdiff inline is the most common use-case.
202 mimetypes.add_type('text/plain', '.debdiff')
203+
204+ # Add support for Launchpad's OWL decription of its RDF metadata.
205+ mimetypes.add_type('application/rdf+xml', '.owl')