Ejemplo n.º 1
0
    def get(self):

        uniqueid = int(self.request.get("uniqueid"))

        # check if we have a cached result
        cache_key = 'venture_%d' % uniqueid
        venture = memcache.get(cache_key)
        # return result from cache if found
        if venture is None:
            logging.info('CACHE MISS: %s' % cache_key)
            # cache miss so get from datastore
            venture = Venture.get_one("uniqueid", uniqueid)

        if venture:
            if venture.approved:
                template = template_env.get_template("venture.html")
                template_vars = {"venture": venture}
            else:
                template = template_env.get_template("unapproved.html")
                template_vars = {"venture": venture}
        else:
            template = template_env.get_template("notfound.html")
            template_vars = {"uniqueid": uniqueid}

        # add template_vars to cache so subsequent checks are quicker
        memcache.set(cache_key, venture)
        self.response.out.write(template.render(template_vars))
Ejemplo n.º 2
0
 def post(self):
     uniqueid = int(cgi.escape(self.request.get("uniqueid")))
     venture = Venture.get_one("uniqueid", uniqueid)
     venture.approved = True
     venture.save()
     # flush cache as state of venture has changed
     memcache.flush_all()
     self.redirect("/admin/venture/?uniqueid=%d" % venture.uniqueid)
Ejemplo n.º 3
0
    def get(self):

        uniqueid = int(self.request.get("uniqueid"))

        # check if we have a cached result
        cache_key = 'venture_image_%s' % uniqueid
        image = memcache.get(cache_key)
        # return result from cache if found
        if image is not None:
            self.response.headers['Content-Type'] = 'image/png'
            self.response.out.write(image)
            return

        logging.info('CACHE MISS: %s' % cache_key)
        venture = Venture.get_one("uniqueid", uniqueid)
        image = venture.logo
        if venture.logo:
            image = images.resize(image, 96, 96)
            self.response.headers['Content-Type'] = 'image/png'
            # add image to cache so subsequent checks are quicker
            memcache.set(cache_key, image)
            self.response.out.write(image)
        else:
            self.abort(404)
Ejemplo n.º 4
0
 def get(self):
     uniqueid = int(self.request.get("uniqueid"))
     venture = Venture.get_one("uniqueid", uniqueid)
     template = template_env.get_template("venture.html")
     template_vars = {"venture": venture}
     self.response.out.write(template.render(template_vars))