def import_to_datastore(): from models import User, Marker from google.appengine.ext import db my_user = User.all().filter("email", "*****@*****.**").get() i = 0 for data in import_data(): old_marker = Marker.get_by_key_name(str(data["id"])) if old_marker: old_marker.delete() marker = Marker( key_name=str(data["id"]), user = my_user, title = "Accident", description = data["description"].decode("utf8"), address = data["address"].decode("utf8"), location = db.GeoPt(data["lat"], data["lng"]), type = Marker.MARKER_TYPE_ACCIDENT, subtype = data["severity"], created = data["date"], modified = data["date"], ) marker.put() marker.update_location() print marker.key().name()
def get(self): timestamps = self.request.params.getall('timestamp') row = self.request.params.get('row_key') for timestamp in timestamps: t = datetime.datetime.fromtimestamp(float(timestamp)) r = db.get(row) m = Marker(time = t, row = r, value = 3) m.put() referer = self.request.environ.get('HTTP_REFERER') if referer: self.redirect(referer) else: show = '/show?key=%s' % row.key() self.redirect(show)