[Secure-testing-commits] r2485 - bin

Florian Weimer fw at costa.debian.org
Thu Oct 20 09:03:04 UTC 2005


Author: fw
Date: 2005-10-20 09:03:03 +0000 (Thu, 20 Oct 2005)
New Revision: 2485

Modified:
   bin/tracker_service.py
Log:
 r628 at deneb:  fw | 2005-10-14 10:35:43 +0200
 bin/tracker_service.py (TrackerService.page_redirect):
   New method.  Invokes page_object_or_redirect.
 (TrackerService.page_object):
   Reimplement in terms of page_object_or_redirect.
 (TrackerService.page_object_or_redirect):
   Display an object page, or redirect to the correct page
   (which can be external).

Modified: bin/tracker_service.py
===================================================================
--- bin/tracker_service.py	2005-10-20 09:02:46 UTC (rev 2484)
+++ bin/tracker_service.py	2005-10-20 09:03:03 UTC (rev 2485)
@@ -50,6 +50,7 @@
         self.db = security_db.DB(db_name)
         self.register('', self.page_home)
         self.register('*', self.page_object)
+        self.register('redirect/*', self.page_redirect)
         self.register('source-package/*', self.page_source_package)
         self.register('binary-package/*', self.page_binary_package)
         self.register('status/release/stable', self.page_status_release_stable)
@@ -119,14 +120,22 @@
 
     def page_object(self, path, params, url):
         obj = path[0]
+        return self.page_object_or_redirect(url, obj, False)
 
+    def page_redirect(self, path, params, url):
+        obj = path[0]
+        return self.page_object_or_redirect(url, obj, True)
+
+    def page_object_or_redirect(self, url, obj, redirect):
+        c = self.db.cursor()
+
         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)
+            return self.page_bug(url, obj, redirect)
 
         bugnumber = 0
         try:
@@ -134,9 +143,13 @@
         except ValueError:
             pass
         if bugnumber:
-            return self.page_debian_bug(url, bugnumber)
+            buglist = list(self.db.getBugsFromDebianBug(c, bugnumber))
+            if buglist:
+                return self.page_debian_bug(url, bugnumber, buglist)
+            if redirect:
+                return RedirectResult(self.url_debian_bug(url, str(bugnumber)),
+                                      permanent=False)
 
-        c = self.db.cursor()
         if self.db.isSourcePackage(c, obj):
             return RedirectResult(self.url_source_package(url, obj, full=True))
         if  self.db.isBinaryPackage(c, obj):
@@ -144,13 +157,17 @@
 
         return self.page_not_found(url, obj)
 
-    def page_bug(self, url, name):
+    def page_bug(self, url, name, redirect):
         cursor = self.db.cursor()
         try:
             bug = bugs.BugFromDB(cursor, name)
         except ValueError:
+            if redirect:
+                if name[0:4] in ('CAN-', 'CVE-'):
+                    return RedirectResult(self.url_cve(url, name),
+                                          permanent=False)
             return self.page_not_found(url, name)
-        if bug.name <> name:
+        if bug.name <> name or redirect:
             # Show the normalized bug name in the browser address bar.
             return RedirectResult(url.scriptRelativeFull(bug.name))
 
@@ -301,29 +318,23 @@
 
         return self.create_page(url, bug.name, page)
 
-    def page_debian_bug(self, url, bugnumber):
-        buglist = list(self.db.getBugsFromDebianBug(self.db.cursor(),
-                                                    bugnumber))
-        if buglist:
-            if len(buglist) == 1:
-                # Single issue, redirect.
-                return RedirectResult(url.scriptRelativeFull(buglist[0][0]))
+    def page_debian_bug(self, url, bugnumber, buglist):
+        if len(buglist) == 1:
+            # Single issue, redirect.
+            return RedirectResult(url.scriptRelativeFull(buglist[0][0]))
 
-            def gen():
-                for (name, urgency, description) in buglist:
-                    if urgency == "unknown":
-                        urgency = ""
-                    yield self.make_xref(url, name), urgency, description
+        def gen():
+            for (name, urgency, description) in buglist:
+                if urgency == "unknown":
+                    urgency = ""
+                yield self.make_xref(url, name), urgency, description
 
-            return self.create_page(
-                url, "Information related to Debian bug #%d" % bugnumber,
-                [P("The following issues reference to Debian bug ",
-                   self.make_debian_bug(url, bugnumber), ":"),
-                 make_table(gen(),
-                            caption=("Name", "Urgency", "Description"))])
-                    
-        else:
-            return self.page_not_found(url, str(bugnumber))
+        return self.create_page(
+            url, "Information related to Debian bug #%d" % bugnumber,
+            [P("The following issues reference to Debian bug ",
+               self.make_debian_bug(url, bugnumber), ":"),
+             make_table(gen(),
+                        caption=("Name", "Urgency", "Description"))])
 
     def page_not_found(self, url, query):
         return self.create_page(url, 'Not found',




More information about the Secure-testing-commits mailing list