def put_user(self, uid, first_name, last_name, email): user = User( key_name = uid, first_name = first_name, last_name = last_name, email = email, stations = self.stations, ) user.put() logging.info("User put in datastore") # Put the user in the proxy self._user = user # Increment admin counter of users admin_proxy = AdminApi() admin_proxy.increment_users_counter() logging.info("Counter of users incremented") # Mail new user to admins self.mail() return self._user
def user(self): if not hasattr(self, "_user"): self._user = memcache.get(self._memcache_user_id) if self._user is None: logging.info("User not in memcache") self._user = User.get_by_key_name(self._uid) if self._user: memcache.set(self._memcache_user_id, self._user) logging.info("%s %s put in memcache"%(self._user.first_name, self._user.last_name)) else: logging.info("User does not exist") else: logging.info("%s %s already in memcache"%(self._user.first_name, self._user.last_name)) return self._user