def require_source(method):
    """Decorator that ensures source is set on the object the called
       method belongs to."""
    def wrapped(self, *args, **kwargs):
        if self.source is None:
            raise ValueError("source hasn't been set")
        return method(self, *args, **kwargs)
    return wrapped