Author: fw Date: 2006-01-17 18:46:14 +0000 (Tue, 17 Jan 2006) New Revision: 3311 Modified: bin/tracker_service.py Log: bin/tracker_service.py (TrackerService.page_object_or_redirect): Handle FAKE-nnn objects. (TrackerService.page_debian_bug): Make this method usable for dealing with FAKE-nnn objects. Modified: bin/tracker_service.py ==================================================================--- bin/tracker_service.py 2006-01-17 18:44:18 UTC (rev 3310) +++ bin/tracker_service.py 2006-01-17 18:46:14 UTC (rev 3311) @@ -188,24 +188,31 @@ if not obj: # Redirect to start page. return RedirectResult(url.scriptRelativeFull("")) - - if ''A'' <= obj[0] <= ''Z'': - # Bug names start with a capital letter. - return self.page_bug(url, obj, redirect) + # Attempt to decode a bug number. FAKE-nnn bugs (but not + # FAKE-nnn-mmm bugs) are treated as bug references, too. bugnumber = 0 + fake_bug = False try: - bugnumber = int(obj) + if obj[0:5] == ''FAKE-'': + bugnumber = int(obj[5:]) + fake_bug = True + else: + bugnumber = int(obj) except ValueError: pass if bugnumber: buglist = list(self.db.getBugsFromDebianBug(c, bugnumber)) if buglist: - return self.page_debian_bug(url, bugnumber, buglist) + return self.page_debian_bug(url, bugnumber, buglist, fake_bug) if redirect: return RedirectResult(self.url_debian_bug(url, str(bugnumber)), permanent=False) + if ''A'' <= obj[0] <= ''Z'': + # Bug names start with a capital letter. + return self.page_bug(url, obj, redirect) + if self.db.isSourcePackage(c, obj): return RedirectResult(self.url_source_package(url, obj, full=True)) if self.db.isBinaryPackage(c, obj): @@ -396,7 +403,18 @@ return self.create_page(url, bug.name, page) - def page_debian_bug(self, url, bugnumber, buglist): + def page_debian_bug(self, url, bugnumber, buglist, fake_bug): + if fake_bug: + new_buglist = [] + for b in buglist: + (bug_name, urgency, description) = b + if bug_name[0:5] == "FAKE-": + new_buglist.append(b) + if len(new_buglist) > 0: + # Only replace the bug list if there are still fake + # bug reports. + buglist = new_buglist + if len(buglist) == 1: # Single issue, redirect. return RedirectResult(url.scriptRelativeFull(buglist[0][0])) @@ -407,9 +425,16 @@ urgency = "" yield self.make_xref(url, name), urgency, description + if fake_bug: + intro = """The URL you used contained a non-stable name +based on a Debian bug number. This name cannot be mapped to a specific +issue. """ + else: + intro = "" + return self.create_page( url, "Information related to Debian bug #%d" % bugnumber, - [P("The following issues reference to Debian bug ", + [P(intro + "The following issues reference to Debian bug ", self.make_debian_bug(url, bugnumber), ":"), make_table(gen(), caption=("Name", "Urgency", "Description"))])