summaryrefslogtreecommitdiffstats
path: root/py-bin/main.py
blob: 39294e0323c9eaf8b3e26378da66c250035baa30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#main url mapper

from utils import BasicHandler, process_request, set_logging_defaults
from jabberman import JabberManager
from login import LoginMixIn
from mail_auth import MailAuthMixIn
from setup import SetupMixIn

set_logging_defaults()

class MainHandler(BasicHandler, MailAuthMixIn, LoginMixIn, SetupMixIn):
	def do_process(self, req):
		command = req.params.get("cmd", "")
		
		if command == "":
			self.login_form(req)
		else:
			if hasattr(self, command):
				method = getattr(self, command)
				if hasattr(method, 'web_callable') and method.web_callable:
					self.jman = JabberManager(self.session)
					method(req)
				else:
					self.invalid_page(req)
			else:
				self.invalid_page(req)
				
	def invalid_page(self, req):
		self.error_page(req, "Ungueltiger Request.")

process_request(MainHandler)