示例#1
0
 def load(cls, email_or_id):
     try:
         user_id = int(email_or_id)
         email = db_conn.get("kitten:user_by_id:%i" % user_id)
     except ValueError:
         email = email_or_id
     user_key = "kitten:users:%s" % email
     user_db_string = db_conn.get(user_key)
     if user_db_string:
         user_serialized = json.loads(user_db_string)
         return cls(**user_serialized)
     else:
         return None
示例#2
0
 def get(cls, id):
     search_request_raw = db_conn.get("kitten:search_request:%i" % id)
     if search_request_raw:
         search_request = json.loads(search_request_raw)
         search_request = cls(**search_request)
         return search_request
     else:
         return None