]> git.ipfire.org Git - people/ms/webapp.git/blob - application/handlers.py
template: Created base layout and substitute only required areas.
[people/ms/webapp.git] / application / handlers.py
1 #!/usr/bin/python
2
3 import socket
4
5 import tornado.web
6
7 class BaseHandler(tornado.web.RequestHandler):
8 def get_current_user(self):
9 return self.get_secure_cookie("user")
10
11 def footer(self):
12 return "%s" % socket.gethostname()
13
14 @property
15 def ldap(self):
16 return self.application.ldap
17
18
19 class MainHandler(BaseHandler):
20 def get(self):
21 if not self.current_user:
22 self.redirect("/login")
23 return
24 self.redirect("/home")
25
26
27 class HomeHandler(BaseHandler):
28 def get(self):
29 self.render("base.html", title="Testsite", slogan="Security now!",
30 footer=self.footer(), user=self.current_user)