Check if the request should be permitted for a given object.
        Raises an appropriate exception if the request is not permitted.

        :param request: Pyramid Request object.
        :param obj: The SQLAlchemy model instance that permissions will be evaluated against.

def check_object_permissions(self, request, obj):
        """
        Check if the request should be permitted for a given object.
        Raises an appropriate exception if the request is not permitted.

        :param request: Pyramid Request object.
        :param obj: The SQLAlchemy model instance that permissions will be evaluated against.
        """

        for permission in self.get_permissions():
            if not permission.has_object_permission(request, self, obj):
                self.permission_denied(request, message=getattr(permission, 'message', None))