Ejemplo n.º 1
0
 def get(self):
     q = Sighting.all()
     points = []
     for result in q:
         point = {}
         if result.coords:
             point["lat"] = result.coords.lat
             point["lon"] = result.coords.lon
             point["address"] = result.address
             image = AttachedImage.gql("WHERE sighting = :1", result).get()
             if image:
                 point["thumbnail"] = "/show_image?id=%s&size=thumb" % image.key().id()
             points.append(point)
     self.response.headers["Content-Type"] = "application/json"
     self.response.out.write(simplejson.dumps(points))
Ejemplo n.º 2
0
    def get(self):
        id = None
        try:
            id = int(self.request.get("id"))
            logging.info("Got id %s", id)
        except ValueError:
            pass
        if id:
            sighting = Sighting.get_by_id(id)
            logging.info("Got sighting %s", sighting.coords)
            images = AttachedImage.gql("WHERE sighting = :1", sighting).fetch(10, 0)

            for image in images:
                logging.info("Got image id = %s", image.key())

            template_params = {"images": images, "sighting": sighting}
        path = os.path.join(os.path.dirname(__file__), "templates/TestTemplat.html")
        self.response.out.write(template.render(path, template_params))
Ejemplo n.º 3
0
    def get(self):
        id = None
        size = "thumb"

        try:
            id = int(self.request.get("id"))
            logging.info("Got id %s", id)
        except ValueError:
            pass

        size = self.request.get("size")

        if id:
            image = AttachedImage.get_by_id(id)
            logging.info("Got image %s", id)
            self.response.headers["Content-Type"] = "image/jpg"
            if size == "thumb":
                self.response.out.write(image.get_thumbnail())
            elif size == "original":
                self.response.out.write(image.original)
            else:
                self.response.out.write(image.get_small())