Пример #1
0
    def __getitem__(self, userid):
        user = self.user_svc.fetch(userid)

        if not user:
            raise KeyError()

        return contexts.UserContext(user)
Пример #2
0
    def __getitem__(self, userid):
        try:
            user = self.user_svc.fetch(userid)
        except InvalidUserId as e:
            # In this context we failed because the user provided a userid
            # we cannot parse, not because it could not be found
            raise HTTPBadRequest(e.args[0]) from e

        if not user:
            raise KeyError()

        return contexts.UserContext(user)