def get(self): units = Unit.gql("where user = :1", users.get_current_user() ) if units.count() == 0: unit = Unit() unit.x = 20 unit.y = 20 unit.user = users.get_current_user() unit.put() units = Unit.gql("where user = :1", users.get_current_user() ) json = {"units":[]} for unit in units: json["units"].append( {"x":unit.x, "y":unit.y, "id":unit.key().id(), "owner":unit.user.nickname() } ) self.response.out.write(demjson.encode(json))
def post(self): unit = Unit() unit.x = int(self.request.get("x")) unit.y = int(self.request.get("y")) unit.user = users.get_current_user() unit.put()