def get(self, path): #linkobj = Link.get_link_by_url(path) #linkobj = Link.get_by_key_name(path) linkobj = Link.gql('WHERE custom_path = :custom_path', custom_path=path).get() #linkobj = Link.get({'custom_path':path}) # , read_policy=db.STRONG_CONSISTENCY) #account for 404, log it. linkobj.count += 1 linkobj.put() self.redirect(linkobj.url)
def getFile(request, fileId): """ Called when we get a request for a LittleShoot-shortened link. This resolves to the "real" url and checks if the caller has LittleShoot. If they do, this just redirects the caller to the file. Otherwise, it redirects them to a page prompting them to install LittleShoot. """ logging.info('Handling request to lookup a file: %s', request.REQUEST.items()) logging.info("File ID: %s", fileId) keyId = base62.to_decimal(fileId) key = db.Key.from_path("Link", keyId) keyQuery = Link.gql('WHERE __key__ = :1', key) links = keyQuery.fetch(1) if (len(links) == 0): logging.warn("No match for file ID: %s", fileId) return HttpResponseNotFound("Could not find a matching file") link = links[0] link.usageCount += 1 link.save() url = link.url logging.info("Link is: %s", url) littleShootPresent = appChecker.supportsLinks(request) if littleShootPresent: logging.info('Found LittleShoot') return HttpResponseRedirect(url) else: logging.info('Sending to link not installed page...') uri = link.url title = link.title return render_to_response('aboutTab.html', {'link' : uri, 'title' : title, 'tabId' : 'forthTab', 'tabJavaScriptClass' : 'AboutTab', 'homeSelected' : True, 'showLinkNotInstalled': True})