def post(self): user_id = users.get_current_user().user_id() user = User.get_by_key_name('key:' + user_id) if not user: location = db.GeoPt(float(self.request.get('lat')), float(self.request.get('lng'))) square = geo.hashArea(location) user = User(key_name='key:' + user_id, home=location, area=square) user.user = users.get_current_user() country = self.request.get('country') #Can use memcache here if geo.country_currency.has_key(country): user.currency = geo.country_currency[country].decode('utf-8') else: user.currency = '$' else: user.home = db.GeoPt(float(self.request.get('lat')), float(self.request.get('lng'))) user.area = geo.hashArea(user.home) country = self.request.get('country') if geo.country_currency.has_key(country): user.currency = geo.country_currency[country].decode('utf-8') else: user.currency = '$' #TODO: Update location of all user items? # TODO: COunter not working # if not city.users: # city.users = 1 # else: # city.users = city.users + 1 #user.city = city user.put() logging.info('wrote user to database = ' + str(user.key())) json_response = simplejson.dumps({'currency': user.currency}) self.response.out.write(json_response)