A decorator to commit to the storage if autocommit is set to True.

def autocommit(f):
    "A decorator to commit to the storage if autocommit is set to True."
    @wraps(f)
    def wrapper(self, *args, **kwargs):
        result = f(self, *args, **kwargs)
        if self._meta.commit_ready():
            self.commit()
        return result
    return wrapper