def check(self, user, permission, obj=_nothing):
        """Raises AuthorizationError when a user has no permission.

        :param user: a user.
        :param permission: permission to check.
        :param obj: (optional) an object to check permission for.
        """
        if not self.allows(user, permission, obj):
            raise AuthorizationError(
                'Can\'t {} object of class {}'.format(
                    permission, type(obj)))
Raises AuthorizationError when a user has no permission.

        :param user: a user.
        :param permission: permission to check.
        :param obj: (optional) an object to check permission for.