Code review comment for lp:~tvansteenburgh/charm-helpers/config-implicit-save

Revision history for this message
Tim Van Steenburgh (tvansteenburgh) wrote :

> I don't think using the destructor is the right thing to do. It will cause the
> changes to be persisted even if the hook fails.
>
> The sanest place I can think of to save the config only on successful
> termination is in the @hooks.hook decorator.

Good observation. Doing the save in the @hooks.hook will be difficult since there is not a global Config object.

Can you think of a downside of doing this instead:

```
def __del__(self):
    if self.implicit_save and not sys.exc_type:
        self.save()
```

« Back to merge proposal