def get(self, nb): logging.info(">>> " + self.request.url + " >>>AccessViaB64ShortUrl") nb = pb64.decodeB64Padless(nb) if nb: # Get the full url corresponding to count q = db.GqlQuery("SELECT * FROM URLs WHERE counter = :1", nb) urls = q.fetch(1) if len(urls) == 1: matches = re.findall(utils.regexp["parseFullUrlWithSeconds"], urls[0].url) if len(matches) == 0: matches = re.findall(utils.regexp["parseFullUrl"], urls[0].url) try: target = matches[0][0] options = matches[0][1] or "" title = matches[0][2] or "" subHandler = CountDownDMYHMS() subHandler.request = self.request subHandler.response = self.response subHandler.get(target, options, title) except: #print sys.exc_info() # TODO: need error management for the user here self.redirect("/") else: #print sys.exc_info() # TODO: need error management for the user here self.redirect("/") else: # TODO: need error management for the user here self.redirect("/")
def get(self, indexB64): index = pb64.decodeB64Padless(indexB64) if index: logger.info(self, "Getting page at index: " + indexB64 + " (b64: " + str(index) + ")") pagedata = modelaccess.getPageData(index) if pagedata: template = pagedata["template"] pagedata["template"] = None jsondata = simplejson.dumps(pagedata, cls=jsondateutils.JsonDatesEncoder) pagedata.update({"json": jsondata, "html": template}) modelaccess.incrementPageUsage(index) self.sendTemplateResponse("page.html", pagedata) else: self.send404Response() else: self.send404Response()