Merge lp:~wgrant/launchpad/bug-736633 into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 12614
Proposed branch: lp:~wgrant/launchpad/bug-736633
Merge into: lp:launchpad
Diff against target: 28 lines (+4/-2)
2 files modified
lib/canonical/librarian/ftests/test_web.py (+3/-1)
lib/canonical/librarian/web.py (+1/-1)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-736633
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+53746@code.launchpad.net

Commit message

[r=lifeless][bug=736633] 404 on invalid old librarian URLs instead of crashing.

Description of the change

The librarian's old URL handler (parsing paths of the form /content/alias/filename) breaks when handling a non-integral alias ID. Trivial fix.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/librarian/ftests/test_web.py'
--- lib/canonical/librarian/ftests/test_web.py 2011-02-24 04:33:55 +0000
+++ lib/canonical/librarian/ftests/test_web.py 2011-03-17 06:56:36 +0000
@@ -159,9 +159,11 @@
159 old_url = uri_path_replace(url, str(aid), '42/%d' % aid)159 old_url = uri_path_replace(url, str(aid), '42/%d' % aid)
160 self.assertEqual(urlopen(old_url).read(), 'sample')160 self.assertEqual(urlopen(old_url).read(), 'sample')
161161
162 # If the content id is not an integer, a 404 is raised162 # If the content and alias IDs are not integers, a 404 is raised
163 old_url = uri_path_replace(url, str(aid), 'foo/%d' % aid)163 old_url = uri_path_replace(url, str(aid), 'foo/%d' % aid)
164 self.require404(old_url)164 self.require404(old_url)
165 old_url = uri_path_replace(url, str(aid), '%d/foo' % aid)
166 self.require404(old_url)
165167
166 def test_404(self):168 def test_404(self):
167 client = LibrarianClient()169 client = LibrarianClient()
168170
=== modified file 'lib/canonical/librarian/web.py'
--- lib/canonical/librarian/web.py 2010-10-25 20:42:59 +0000
+++ lib/canonical/librarian/web.py 2011-03-17 06:56:36 +0000
@@ -80,7 +80,7 @@
80 self.aliasID = int(filename)80 self.aliasID = int(filename)
81 except ValueError:81 except ValueError:
82 log.msg(82 log.msg(
83 "404 (old URL): alias is not an int: %r" % (name,))83 "404 (old URL): alias is not an int: %r" % (filename,))
84 return fourOhFour84 return fourOhFour
85 filename = request.postpath[0]85 filename = request.postpath[0]
8686