Пример #1
0
    def get_one(cls, obj_id):
        if not cls.key_prefix:
            raise Exception("Key prefix not defined!")

        if not obj_id:
            return None

        obj_str = redis_conn.get("%s:%s" % (cls.key_prefix, obj_id))
        if not obj_str:
            return None

        obj_json = json.loads(obj_str)
        return cls(**obj_json)
Пример #2
0
    def get_by_email(cls, email):
        max_id = redis_conn.get("%s:id" % cls.key_prefix)
        if not max_id:
            return None

        for idx in xrange(1, int(max_id) + 1):
            user = cls.get_one(idx)
            if not user:
                continue

            if user.email == email:
                return user
        return None
Пример #3
0
def get_req_input(key):
  data = json.loads(redis_conn.get(key))
  program, extension, problem_id = data['program'], data['extension'], data['problem']
  return program, extension, problem_id
Пример #4
0
 def get(cls, board_id):
     b_str = r.get("b_%s" % board_id)
     if not b_str:
         return None
     b_json = json.loads(b_str)
     return Board(**b_json)