Decorator for ``Document`` methods that change the document.

    This decorator ensures that the object's caches are kept in sync
    when changes are made.

def mutator(*cache_names):
    """Decorator for ``Document`` methods that change the document.

    This decorator ensures that the object's caches are kept in sync
    when changes are made.

    """
    def deco(fn):
        @wraps(fn)
        def _fn(self, *args, **kwargs):
            try:
                return fn(self, *args, **kwargs)
            finally:
                for cache_name in cache_names:
                    setattr(self, cache_name, None)

        return _fn

    return deco