summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2008-06-24 08:48:25 +0200
committerSean Finney <seanius@debian.org>2008-06-24 08:48:25 +0200
commitcd7927dbcaabf7958ccffb0e4daaaf2e9a0a9b08 (patch)
treebdccfc28b7b374a1e9aa5fe34d156025a22d517a
parentd59308962f37e1c723792837d9603ed093d2501b (diff)
downloadpatch-tracker-cd7927dbcaabf7958ccffb0e4daaaf2e9a0a9b08.tar.gz
remove hardcoded url assumptions
pagehandler now parses commands relative to Conf.root_url (which really should be called something else, like Conf.base_dir), allowing for both flexible subdir-based installs and vhost based installs.
-rw-r--r--TODO5
-rwxr-xr-xpagehandler.py23
2 files changed, 13 insertions, 15 deletions
diff --git a/TODO b/TODO
index af23e34..0e8e592 100644
--- a/TODO
+++ b/TODO
@@ -2,11 +2,6 @@ welcome to the TODO file.
== short-range TODO ==
-remove hardcoded url parsing
-
- pagehandler currently assumes installation under a certain subdir,
- which isn't at all necessary.
-
better handling of more exotic patch systems
for example:
diff --git a/pagehandler.py b/pagehandler.py
index 9fc6d9c..48d6cb4 100755
--- a/pagehandler.py
+++ b/pagehandler.py
@@ -14,17 +14,20 @@ from pygments.lexers import DiffLexer
from pygments.formatters import HtmlFormatter
class CmdHandler:
- def __init__(self, req_uri):
+ def __init__(self, uri):
+ if len(uri)<len(Conf.root_url) or uri[0:len(Conf.root_url)]!=Conf.root_url:
+ self.error("Invalid URL!")
+
self.db = PatchTrackerDB()
- args = req_uri.split("/")
- self.cmd = args[2]
- # XXX this assumes http://site/foo/patch/adsfadf
+ args = uri[len(Conf.root_url)+1:].split("/")
+ print "args:",args
+ self.cmd = args[0]
if self.cmd == "patch":
- patchtype,mode,pkgname,version = args[3:7]
+ patchtype,mode,pkgname,version = args[1:5]
self.parsemode(mode)
dh = self.make_diffhandler(pkgname,version)
if patchtype == "series":
- self.patchname = args[7]
+ self.patchname = args[5]
self.content = dh.series().fetch(self.patchname)
elif patchtype == "debianonly":
self.patchname = "debian-dir only changes"
@@ -38,14 +41,14 @@ class CmdHandler:
self.version = version
elif self.cmd == "package":
self.db.setFactory(DB.srcpkg_factory)
- self.name = args[3]
- self.version = args[4]
+ self.name = args[1]
+ self.version = args[2]
self.srcpkg = self.db.findSourcePackage(self)
elif self.cmd == "index":
- if len(args) < 4 or not len(args[3]):
+ if len(args) < 2 or not len(args[1]):
self.error("please provide a letter on which to index")
else:
- self.letter = args[3]
+ self.letter = args[1]
self.toc = self.db.findLetterToc(self.letter)
else:
# XXX better way to set up "frontpage"