Пример #1
0
 def post(self):
     from google.appengine.ext.db import BadValueError
     from model import UniqueConstraintViolation
     try:
         RedirectRoutes.create(
         target_key = self.request.get('target_key'),
         target_url = self.request.get('target_url'),
             )
         self.redirect('/')
     except UniqueConstraintViolation:
         self.response.out.write("The target Key already exists , Please go back and try a different key")
     except BadValueError:
         self.response.out.write("Woah there ! That was not a url , Go back and enter a proper one .")
Пример #2
0
 def get(self,target_key):
     import logging
     r = RedirectRoutes.get_by_key_name(target_key)
     if r:
         logging.info("Redirected to :"+str(r.target_url)+"\n"+str(self.request.headers))
         self.redirect(str(r.target_url))
     else:
         self.error(404);
Пример #3
0
 def get(self):
     from google.appengine.api import users
     template_values={
         'self':self,
         'current_user':users.get_current_user(),
         'logout_url':users.create_logout_url(self.request.uri),
         'redirectors':RedirectRoutes.all().filter('author =', users.get_current_user() ),
     }
     path = os.path.join(os.path.dirname(__file__), 'templates/index.html')
     self.response.out.write(template.render(path , template_values))
Пример #4
0
 def post(self):
     key = self.request.get('key')
     RedirectRoutes.get(key).delete()
     self.redirect ('/')