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))
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))