Mercurial > treepkg > treepkg
diff treepkg/status.py @ 464:5fda6768bef6
Enable a status_hook to be set and executed on status changes
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 09 Sep 2010 14:26:35 +0000 |
parents | 27824d3add92 |
children |
line wrap: on
line diff
--- a/treepkg/status.py Thu Sep 09 13:49:37 2010 +0000 +++ b/treepkg/status.py Thu Sep 09 14:26:35 2010 +0000 @@ -121,11 +121,12 @@ # Derived classes may extend a copy of this set with more instance # variables. - _attrs = set(["_filename", "_values"]) + _attrs = set(["_filename", "_values", "_after_setattr"]) - def __init__(self, filename): + def __init__(self, filename, after_setattr=None): self._values = dict() self._filename = filename + self._after_setattr = after_setattr if self._filename is not None: assert os.path.isabs(self._filename) self.read() @@ -178,6 +179,8 @@ if attr in self._fields: self._values[attr] = value self.write() + if self._after_setattr is not None: + self._after_setattr(self, attr) elif attr in self._attrs: self.__dict__[attr] = value else: