def get(self, code, format): if (code is None): logging.info("someone thinking about crafting a URL") MainView.render(self, 200, None, format) return ip = self.request.remote_addr 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: u = Urly.find_or_create_by_href(href) if u is not None: logging.info("creating urly by href: %s", str(href)) MainView.render(self, 200, u, format, href, title) else: logging.info("error creating urly by href: %s", str(href)) MainView.render(self, 400, None, format, href) except db.BadValueError: # href parameter is bad logging.info("error with parameter") MainView.render(self, 400, None, format, href) else: u = Urly.find_by_code(str(code)) if u is not None: logging.info("http://logg.ly/%s redirecting to %s for %s" % (code, u.href, ip)) MainView.render(self, 200, u, format) else: logging.info("redirecting to loggly.com/%s" % code) self.redirect('http://www.loggly.com/%s' % code)
def get(self, code, format): server = "http://" + self.request.environ["HTTP_HOST"]+"/" logging.info("*** Server is %s" % server) if (code is None): logging.info("*** Code is None") MainView.render(self, 200, None, format) return logging.info("*** Code is %s" % code) 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): logging.info("href is %s" % href) try: u = Urly.find_or_create_by_href(href) if u is not None: logging.debug("Rendering with server %s" % server) MainView.render(self, 200, u, format, href, title,server) else: logging.error("Error creating urly by href: %s", str(href)) MainView.render(self, 400, None, format, href) except db.BadValueError: # href parameter is bad MainView.render(self, 400, None, format, href) else: u = Urly.find_by_code(str(code)) if u is not None: MainView.render(self, 200, u, format,href,title,server) else: MainView.render(self, 404, None, format)
def get(self, code, format): if (code is None): MainView.render(self, 200, None, format) return base = self.request.get('href') params = self.request.arguments() for p in params: if (p != 'href') and (p != 'title'): base += '&'+str(p).strip()+'='+self.request.get(p).strip() href = base.strip().encode('utf-8') title = self.request.get('title').strip().encode('utf-8') if (code == 'new') and (href is not None): try: u = Urly.find_or_create_by_href(href) if u is not None: MainView.render(self, 200, u, format, href, title) else: logging.error("Error creating urly by href: %s", str(href)) MainView.render(self, 400, None, format, href) except db.BadValueError: # href parameter is bad MainView.render(self, 400, None, format, href) else: u = Urly.find_by_code(str(code)) if u is not None: MainView.render(self, 200, u, format) else: MainView.render(self, 404, None, format)
def head(self, code, format): if (code is None): self.error(400) else: u = Urly.find_by_code(str(code)) if u is not None: self.redirect(u.href) else: self.error(404)
def get(self, code, format): if (code is None): MainView.render(self, 200, None, format) user = users.get_current_user() if user: self.response.out.write("<a href=\"" + users.create_logout_url('/') + "\">Logout</a>") return u = Urly.find_by_code(str(code)) if u is not None: MainView.render(self, 200, u, format, preview=True) else: MainView.render(self, 404, None, format)
def get(self, code, format): if (code is None): MainView.render(self, 200, None, format) 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: u = Urly.find_or_create_by_href(href) if u is not None: MainView.render(self, 200, u, format, href, title) else: logging.error("Error creating urly by href: %s", str(href)) MainView.render(self, 400, None, format, href) except db.BadValueError: # href parameter is bad MainView.render(self, 400, None, format, href) else: u = Urly.find_by_code(str(code)) if u is not None: MainView.render(self, 200, u, format) else: MainView.render(self, 404, None, format)
def get(self, code, format): if code is None: MainView.render(self, 200, None, format) 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: u = Urly.find_or_create_by_href(href) if u is not None: MainView.render(self, 200, u, format, href, title) else: logging.error("Error creating urly by href: %s", str(href)) MainView.render(self, 400, None, format, href) except db.BadValueError: # href parameter is bad MainView.render(self, 400, None, format, href) else: u = Urly.find_by_code(str(code)) if u is not None: MainView.render(self, 200, u, format) else: MainView.render(self, 404, None, format)