diff options
author | Sean Finney <seanius@debian.org> | 2008-06-26 01:55:58 +0200 |
---|---|---|
committer | Sean Finney <seanius@debian.org> | 2008-06-26 01:55:58 +0200 |
commit | bb37cf116269d5948d7f4d592557642696b5d9c7 (patch) | |
tree | 279809d4fd86e92043e5f8b70dbf2d502d902678 /pagehandler.py | |
parent | d08d138655cce56e9e10c4afbc01ccf4eb55a69e (diff) | |
download | patch-tracker-bb37cf116269d5948d7f4d592557642696b5d9c7.tar.gz |
package search / versionless implementation
going to /packages/pkg now gives a table of contents with
the available versions for the package, or the results of
a widers search in the case of no exact matches
also removed a bunch of dead code from DB mostly
Diffstat (limited to 'pagehandler.py')
-rwxr-xr-x | pagehandler.py | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/pagehandler.py b/pagehandler.py index eba862f..ea01be1 100755 --- a/pagehandler.py +++ b/pagehandler.py @@ -5,7 +5,7 @@ import cgi import os import sys import patchtracker.Conf as Conf -from patchtracker.Templates import ErrorTemplate, PatchTemplate, PackageVersTemplate, LetterTocTemplate, FrontPageTemplate +from patchtracker.Templates import ErrorTemplate, PatchTemplate, PackageVersTemplate, LetterTocTemplate, FrontPageTemplate, SearchResultsTemplate from patchtracker.DiffGzHandler import DiffGzHandler import patchtracker.DB as DB from patchtracker.DB import PatchTrackerDB @@ -83,15 +83,28 @@ class PatchCmd: class PackageCmd: def __init__(self, args): - self.db = PatchTrackerDB() - self.db.setFactory(DB.srcpkg_factory) + db = PatchTrackerDB() self.name = args[0] - self.version = args[1] - self.srcpkg = self.db.findSourcePackage(self) + if len(args) > 1: + version = args[1] + else: + version = None + self.toc = db.findCollection(package=self.name, version=version) + if self.toc.size() == 0: + self.toc = db.findCollection(package="%"+self.name+"%", version=version) def output(self): - print "Content-Type: text/html\n\n" - print PackageVersTemplate(self.srcpkg) + plist = self.toc.getletter(self.name) + if not plist or len(plist) == 0: + error("can't find any package named or containing '%s'"%self.name) + else: + p = self.toc.getpackage(self.name) + print "Content-Type: text/html\n\n" + if not p or len(p) > 1: + print SearchResultsTemplate(self.name, self.toc) + else: + print PackageVersTemplate(p.popitem()[1]) + class IndexCmd: def __init__(self, args): @@ -112,9 +125,8 @@ class JumpCmd: self.name = form.getfirst("package") def output(self): - print "Location: http://%s%s/index/%s#%s\n\n"%( - os.getenv("HTTP_HOST"), Conf.root_url, - SourceArchive.getidx(self.name), self.name) + print "Location: http://%s%s/package/%s\n\n"%( + os.getenv("HTTP_HOST"), Conf.root_url, self.name) class FrontPageCmd: def __init__(self): |