def get(self): address = "" lat = "" long = "" id = None species = "" geohash = "" try: id = int(self.request.get("id")) logging.info("Got id %s", id) except ValueError: pass template_params = {"sighting": None} if id: template_params["sighting"] = Sighting.get_by_id(id) q = Sighting.all() all_sightings = [] for result in q: all_sightings.append(result) template_params["all_sightings"] = all_sightings path = os.path.join(os.path.dirname(__file__), "templates/record_sighting_form.html") self.response.out.write(template.render(path, template_params))
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): address = "" lat = "" long = "" id= None species = "" geohash = "" try: id = int(self.request.get('id')) logging.info("Got id %s", id); except ValueError: pass if id: #key = db.Key.from_path('Sighting', id) #logging.info("Got key %s", key); #logging.info("Got key id %s", key.id()); sighting = Sighting.get_by_id(id) logging.info("Got sighting %s", sighting.coords); address = sighting.address if sighting.coords: lat = sighting.coords.lat long = sighting.coords.lon geohash = sighting.geohash logging.info("Got geohash %s", geohash); species = str(sighting.species) self.response.out.write(''' <html> <head> <title>Record a new sighting...</title> </head> <body onload="initialize()"> <form action = "record_sighting" enctype="multipart/form-data" method = "POST"> Species: <input name = "species" type = "text" value = "%s"/><br> Address: <input name = "address" type = "text" value = "%s"/><br> geohash: <input disabled name = "geohash" type = "text" value = "%s"/><br> Lat: <input disabled name = "lat" type = "text" value = "%s"/><br> long: <input disabled name = "long" type = "text" value = "%s" /><br> image: <input type="file" name="img"/><br> comment: <input type="textarea" name="comment"/><br> submit: <input name = "save" type = "submit"/><br> </form> </body> </html> ''' % (species, address, geohash,lat, long)) self.response.out.write("<table>"); 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 points.append(point) self.response.out.write("<tr><td><a href='/view_sighting?id=%s'>%s</a>(%s, %s) %s</td></tr>" % (result.key().id(),result.address, result.coords.lat, result.coords.lon, result.geohash)) self.response.out.write("</table>");