def user_bind_sid(message): """ 绑定 user 和 sid """ user_id = message['user_id'] sid = message['sid'] user = User.get_by_id(user_id) user.sid = sid user.save()
def load_user(user_id): return User.get_by_id(int(user_id))