summaryrefslogtreecommitdiff
path: root/pagehandler.py
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2008-06-22 18:14:43 +0200
committerSean Finney <seanius@debian.org>2008-06-22 18:14:43 +0200
commit7e5c12673d68d667a42e4cb1c0fa74ddf6e04b01 (patch)
treeac270caa8908016532f9674c14594ae08be8debd /pagehandler.py
parent8581e7dfe8a68c4398823e05a2d8c675eb13100a (diff)
downloadpatch-tracker-7e5c12673d68d667a42e4cb1c0fa74ddf6e04b01.tar.gz
big commit with db and cgi handling updates
i know it's bad form to lump this all together. oh well :p gen-patch-info now does very little besides processing packages and updating the relevant database entries. pretty much everything else is dynamically generated from pagehandler.py now.
Diffstat (limited to 'pagehandler.py')
-rwxr-xr-xpagehandler.py45
1 files changed, 37 insertions, 8 deletions
diff --git a/pagehandler.py b/pagehandler.py
index 858534b..9fc6d9c 100755
--- a/pagehandler.py
+++ b/pagehandler.py
@@ -5,17 +5,21 @@ import cgi
import os
import sys
import patchtracker.Conf as Conf
-from patchtracker.Writers import ErrorTemplate, PatchTemplate
+from patchtracker.Writers import ErrorTemplate, PatchTemplate, PackageVersTemplate, LetterTocTemplate, FrontPageTemplate
from patchtracker.DiffGzHandler import DiffGzHandler
+import patchtracker.DB as DB
+from patchtracker.DB import PatchTrackerDB
import pygments
from pygments.lexers import DiffLexer
from pygments.formatters import HtmlFormatter
class CmdHandler:
def __init__(self, req_uri):
+ self.db = PatchTrackerDB()
args = req_uri.split("/")
+ self.cmd = args[2]
# XXX this assumes http://site/foo/patch/adsfadf
- if args[2] == "patch":
+ if self.cmd == "patch":
patchtype,mode,pkgname,version = args[3:7]
self.parsemode(mode)
dh = self.make_diffhandler(pkgname,version)
@@ -32,8 +36,21 @@ class CmdHandler:
self.error("unhandled patch type '%s'"%(patchtype))
self.pkgname = pkgname
self.version = version
+ elif self.cmd == "package":
+ self.db.setFactory(DB.srcpkg_factory)
+ self.name = args[3]
+ self.version = args[4]
+ self.srcpkg = self.db.findSourcePackage(self)
+ elif self.cmd == "index":
+ if len(args) < 4 or not len(args[3]):
+ self.error("please provide a letter on which to index")
+ else:
+ self.letter = args[3]
+ self.toc = self.db.findLetterToc(self.letter)
else:
- self.error("unhandled command: '%s'"%(args[2]))
+ # XXX better way to set up "frontpage"
+ self.index = self.db.findMasterIndex()
+ self.cmd = "frontpage"
# XXX this assumes to much hard coded, but until there's a faster
# XXX (i.e. database) way to query sourcepackage/diffs it will
@@ -67,13 +84,25 @@ class CmdHandler:
sys.exit(1)
def output(self):
- if self.mode == "dl":
- print "Content-Type: text/x-diff\n\n"
- print self.content
- else:
+ if self.cmd == "patch":
+ if self.mode == "dl":
+ print "Content-Type: text/x-diff\n\n"
+ print self.content
+ else:
+ print "Content-Type: text/html\n\n"
+ print PatchTemplate(pkg=self.pkgname,vers=self.version,patch=self.content,name=self.patchname)
+ elif self.cmd == "package":
+ print "Content-Type: text/html\n\n"
+ print PackageVersTemplate(self.srcpkg,"XXX FIXME")
+ elif self.cmd == "index":
+ print "Content-Type: text/html\n\n"
+ print LetterTocTemplate(self.letter, self.toc)
+ elif self.cmd == "frontpage":
print "Content-Type: text/html\n\n"
- print PatchTemplate(pkg=self.pkgname,vers=self.version,patch=self.content,name=self.patchname)
+ print FrontPageTemplate(self.index)
if __name__ == "__main__":
uri = os.getenv("REQUEST_URI")
+ if not uri:
+ uri = sys.argv[1]
CmdHandler(uri).output()