def check(self, app, environ, start_response): url = request.path fields = dict(request.GET) if fields.has_key('hash'): dburl = URLHash.find_by_hash(fields['hash']).url if dburl is not None: if url.startswith(dburl): return app(environ, start_response) raise NotAuthorizedError( "You are not authorised to view this page" )
def lookup(self, hash): c.hash = URLHash.find_by_hash(hash) if c.hash is None: abort(404, "Sorry, Invalid Hash.") return self.transfer(url=c.hash.url)