Merge lp:~mnordhoff/loggerhead/relative-links into lp:loggerhead

Proposed by Matt Nordhoff
Status: Merged
Approved by: Martin Albisetti
Approved revision: 419
Merged at revision: 416
Proposed branch: lp:~mnordhoff/loggerhead/relative-links
Merge into: lp:loggerhead
Diff against target: 101 lines (+19/-14)
5 files modified
loggerhead/apps/branch.py (+10/-5)
loggerhead/apps/config.py (+2/-2)
loggerhead/apps/transport.py (+2/-2)
loggerhead/controllers/download_ui.py (+2/-2)
loggerhead/templates/atom.pt (+3/-3)
To merge this branch: bzr merge lp:~mnordhoff/loggerhead/relative-links
Reviewer Review Type Date Requested Status
Martin Albisetti Approve
Review via email: mp+24767@code.launchpad.net

Commit message

Generate relative links where possible (Michael Hudson, Matt Nordhoff)

Description of the change

Quoting https://code.edge.launchpad.net/~mwhudson/loggerhead/relative-links/+merge/15298:

> This branch generates relative links apart from in redirects.

*This* branch fixes the issues I noticed when reviewing that branch many moons ago, namely that absolute links are necessary in some parts of the Atom feed. The original branch fixed one HTTP redirect to be absolute; this branch fixes the rest too.

There may be other issues. I dunno.

To post a comment you must log in.
Revision history for this message
Martin Albisetti (beuno) :
review: Approve
420. By Matt Nordhoff

NEWS

421. By Matt Nordhoff

Adjust NEWS

Revision history for this message
Robert Collins (lifeless) wrote :

Looks good enough to eat, to me.

Revision history for this message
Glen Mailer (glenjamin) wrote :

This appears to have broken the "To get this branch, use:" part, which i suspect will need to be special cased.

Updating diff...

An updated diff will be available in a few minutes. Reload to see the changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loggerhead/apps/branch.py'
2--- loggerhead/apps/branch.py 2010-04-14 17:54:32 +0000
3+++ loggerhead/apps/branch.py 2010-05-05 18:51:27 +0000
4@@ -89,10 +89,15 @@
5 if v is not None:
6 qs.append('%s=%s' % (k, urllib.quote(v)))
7 qs = '&'.join(qs)
8- return request.construct_url(
9- self._environ, script_name=self._url_base,
10- path_info=unicode('/'.join(args)).encode('utf-8'),
11- querystring=qs)
12+ path_info = urllib.quote(
13+ unicode('/'.join(args)).encode('utf-8'), safe='/~:')
14+ if qs:
15+ path_info += '?' + qs
16+ return self._url_base + path_info
17+
18+ def absolute_url(self, *args, **kw):
19+ rel_url = self.url(*args, **kw)
20+ return request.resolve_relative_url(rel_url, self._environ)
21
22 def context_url(self, *args, **kw):
23 kw = util.get_context(**kw)
24@@ -154,7 +159,7 @@
25 path = request.path_info_pop(environ)
26 if not path:
27 raise httpexceptions.HTTPMovedPermanently(
28- self._url_base + '/changes')
29+ self.absolute_url('/changes'))
30 if path == 'static':
31 return static_app(environ, start_response)
32 cls = self.controllers_dict.get(path)
33
34=== modified file 'loggerhead/apps/config.py'
35--- loggerhead/apps/config.py 2009-05-13 13:14:04 +0000
36+++ loggerhead/apps/config.py 2010-05-05 18:51:27 +0000
37@@ -208,8 +208,8 @@
38 environ['SCRIPT_NAME']
39 segment = path_info_pop(environ)
40 if segment is None:
41- raise httpexceptions.HTTPMovedPermanently(
42- environ['SCRIPT_NAME'] + '/')
43+ raise httpexceptions.HTTPMovedPermanently.relative_redirect(
44+ environ['SCRIPT_NAME'] + '/', environ)
45 elif segment == '':
46 response = WSGIResponse()
47 self.browse(response)
48
49=== modified file 'loggerhead/apps/transport.py'
50--- loggerhead/apps/transport.py 2010-05-04 02:31:07 +0000
51+++ loggerhead/apps/transport.py 2010-05-05 18:51:27 +0000
52@@ -69,8 +69,8 @@
53 def app_for_non_branch(self, environ):
54 segment = path_info_pop(environ)
55 if segment is None:
56- raise httpexceptions.HTTPMovedPermanently(
57- environ['SCRIPT_NAME'] + '/')
58+ raise httpexceptions.HTTPMovedPermanently.relative_redirect(
59+ environ['SCRIPT_NAME'] + '/', environ)
60 elif segment == '':
61 if self.name:
62 name = self.name
63
64=== modified file 'loggerhead/controllers/download_ui.py'
65--- loggerhead/controllers/download_ui.py 2010-04-08 01:08:33 +0000
66+++ loggerhead/controllers/download_ui.py 2010-05-05 18:51:27 +0000
67@@ -44,8 +44,8 @@
68 args.append(arg)
69
70 if len(args) < 2:
71- raise httpexceptions.HTTPMovedPermanently(self._branch.url(
72- '../changes'))
73+ raise httpexceptions.HTTPMovedPermanently(
74+ self._branch.absolute_url('../changes'))
75
76 revid = h.fix_revid(args[0])
77 file_id = args[1]
78
79=== modified file 'loggerhead/templates/atom.pt'
80--- loggerhead/templates/atom.pt 2009-06-06 12:23:11 +0000
81+++ loggerhead/templates/atom.pt 2010-05-05 18:51:27 +0000
82@@ -4,8 +4,8 @@
83 bazaar changes for <tal:branch-name content="branch/friendly_name">branch name</tal:branch-name>
84 </title>
85 <updated tal:content="string:${updated}Z">${updated}</updated>
86- <id tal:content="python:branch.url(['/atom'])">url</id>
87- <link rel="self" type="application/atom+xml" tal:attributes="href python:branch.url(['/atom'])" />
88+ <id tal:content="python:branch.absolute_url(['/atom'])">url</id>
89+ <link rel="self" type="application/atom+xml" tal:attributes="href python:branch.absolute_url(['/atom'])" />
90 <link rel="alternate" type="text/html" tal:attributes="href python:branch.url(['/changes'])" />
91
92 <entry tal:repeat="entry changes">
93@@ -16,7 +16,7 @@
94 updated
95 </updated>
96 <!-- TODO: The feed validator will generate warnings because this is URL-encoded -->
97- <id tal:content="python:branch.url(['/revision', entry.revno])">
98+ <id tal:content="python:branch.absolute_url(['/revision', entry.revno])">
99 ID
100 </id>
101 <author tal:repeat="author entry/authors">

Subscribers

People subscribed via source and target branches