def save(self, must_create=False): if must_create: if query("session_create:%s:%s" % (self.session_key, json.dumps(self._get_session( no_load=must_create)))) == "ZUMS.SessionExists": raise CreateError else: query("session_set:%s:%s" % (self.session_key, json.dumps(self._get_session(no_load=must_create))))
def save(self, must_create=False): if must_create: if query( "session_create:%s:%s" % ( self.session_key, json.dumps(self._get_session(no_load=must_create)) ) ) == "ZUMS.SessionExists": raise CreateError else: query( "session_set:%s:%s" % ( self.session_key, json.dumps(self._get_session(no_load=must_create)) ) )
def authenticate(self, username=None, password=None): user_info = query(str("user_authenticate:%s:%s" % (username, password))) if user_info: user_info = json.loads(user_info) try: user = User.objects.get(username=username) except User.DoesNotExist: user = User(username=user_info["username"], password='******') self.update_user_if_required(user, user_info) return user return None
def authenticate(self, username=None, password=None): user_info = query( str("user_authenticate:%s:%s" % (username, password)) ) if user_info: user_info = json.loads(user_info) try: user = User.objects.get(username=username) except User.DoesNotExist: user = User( username=user_info["username"], password='******' ) self.update_user_if_required(user, user_info) return user return None
def delete(self, session_key=None): if session_key is None: if self._session_key is None: return session_key = self._session_key query("session_delete:%s" % session_key)
def exists(self, session_key): return bool(query("session_exists:%s" % session_key))
def create(self): self.session_key = query("session_create") self.modified = True self._session_cache = {}
def load(self): s = query("session_get:%s" % self.session_key) if s.startswith("ZUMSD.Exception:"): return {} return json.loads(s)