Beispiel #1
0
 def get(self):
   #@todo: figure out the page title, surf options and username and pass them to the template
   user = users.get_current_user()
   request = self.request.path[1:].split('/')
   if request[0] == "login.php":
     request[0]="/index.php"
   
   title = dict()
   title["primary"] = request[0]
   menu = ["home","ippitsu2"]
   if not user:
     #user not logged in
     menu.extend(["login","register"])
   else:
     menu.extend(["projects","settings"])
     title["user"] = user.nickname()
     title["logout"] = users.create_logout_url("/")
     fullquery =  self.request.query_string.split('&')
     args = dict()
     if '=' in fullquery[0]: 
       for query in fullquery:
         quer = query.split('=')
         args[quer[0]]=quer[1]
   try:
     #ippitsu2.appspot.com/controller/method/tracker.php?value1=a&value2=b...
     if(len(request)>1):
       title["secondary"] = request[1]
       resp = controller.request(request[0],request[1],args)
     else:
       title["primary"] = "home"
       resp = controller.static.get(request[0])
   except Exception, err:
     e = err.args[0]
     if e == "notfound": 
       path =  os.path.join(os.path.dirname(__file__),'404.html')
       self.response.set_status(404)
       self.response.out.write(template.render(path, {"url":self.request.url}))
     elif e == "notauth":
       path = os.path.join(os.path.dirname(__file__),'401.html')
       self.response.set_status(401)
       self.response.out.write(template.render(path,{"url":self.request.url}))
       logging.info("INFO: User "+str(users.get_current_user())+" tried to access unauthorized content.")
     else:
       raise Exception(traceback.format_exc())
Beispiel #2
0
 def post(self):
   try:
     request = self.request.path[1:].split('/')
     args = dict()
     for arg in self.request.arguments(): args[arg]=self.request.get(arg)
     #ippitsu2.appspot.com/controller/method/tracker.php
     resp = controller.request(request[0],request[1],args)
   except Exception, err:
     e = err.args[0]
     if e == "notfound": 
       path =  os.path.join(os.path.dirname(__file__),'404.html')
       self.response.set_status(404)
       self.response.out.write(template.render(path, {"url":self.request.url}))
     elif e == "notauth":
       path = os.path.join(os.path.dirname(__file__),'401.html')
       self.response.set_status(401)
       self.response.out.write(template.render(path,{"url":self.request.url}))
       logging.info("INFO: User "+user.get_current_user()+" tried to access unauthorized content.")
     else:
       raise Exception(traceback.format_exc())