diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2010-04-07 02:00:49 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2010-04-07 02:00:49 +0200 |
commit | 9764086ee9cc10ad1fe7b7cc6f2be82145f843e3 (patch) | |
tree | a2c16e52d2881fd62f1b053e731c92647d6f3bde /controller.py | |
parent | b0a8979e00abddc538359a1f0c3f57e0c90ff16e (diff) | |
download | web-9764086ee9cc10ad1fe7b7cc6f2be82145f843e3.tar.gz web-9764086ee9cc10ad1fe7b7cc6f2be82145f843e3.tar.bz2 web-9764086ee9cc10ad1fe7b7cc6f2be82145f843e3.zip |
Implemented redirecting
Diffstat (limited to 'controller.py')
-rw-r--r-- | controller.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/controller.py b/controller.py index e694148..7de70f1 100644 --- a/controller.py +++ b/controller.py @@ -1,3 +1,5 @@ +from __future__ import with_statement + import web from renderer import render @@ -9,6 +11,23 @@ class Page: if not name or name == '/': name = 'index' return render(name) +class Redirect: + """ + Redirecting to another page. + """ + + redirects = {} + with open("redirects") as f: + for line in f: + name, url = line.split() + redirects[name.strip()] = url.strip() + + def GET(self, name): + if name not in self.redirects: + raise web.TempRedirect("/") + else: + raise web.Redirect(self.redirects[name], absolute = True) + def FourOhFour(page): """ 404 error page. |