Ejemplo n.º 1
0
 def get(self,code):
     if code is None:
         MainView.render(self,200,None)
         return
     
     href = self.request.get('href').strip().encode('utf-8')
     title= self.request.get('title').strip().encode('utf-8')
     
     if code == 'new' and href is not None:
         try:
             url = PugPe.find_or_create_by_href(href)
             if url is not None:
                 MainView.render(self,200,url,href,title)
             else:
                 logging.error("Error creating urly by href: %s", str(href))
                 MainView.render(self,400,None,href)
         except db.BadValueError:
             #href parameter is bad
             MainView.render(self,400,None,href)
     else:
         url = PugPe.find_by_code(str(code))
         if url is not None:
             MainView.render(self,200,url)
         else:
             MainView.render(self,400,None)
Ejemplo n.º 2
0
 def head(self,code):
     if code is None:
         self.error(400)
     else:
         url = PugPe.find_by_code(str(code))
         if url is not None:
             self.redirect(url.href)
         else:
             self.error(404)