[svn] commit: r3091 - /branches/trac300/src/lib/python/isc/utils/rollback.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Sep 30 20:06:41 UTC 2010
Author: vorner
Date: Thu Sep 30 20:06:29 2010
New Revision: 3091
Log:
Implemented the isc.util.rollback
Modified:
branches/trac300/src/lib/python/isc/utils/rollback.py
Modified: branches/trac300/src/lib/python/isc/utils/rollback.py
==============================================================================
--- branches/trac300/src/lib/python/isc/utils/rollback.py (original)
+++ branches/trac300/src/lib/python/isc/utils/rollback.py Thu Sep 30 20:06:29 2010
@@ -31,14 +31,14 @@
"""
def __init__(self):
"""A constructor."""
- pass
+ self.__actions = []
def __enter__(self):
"""
Entry point to the context. It only returns itself, so it
can be used in the with-as statement.
"""
- pass
+ return self
def __exit__(self, exc_type, exc_val, exc_tb):
"""
@@ -46,10 +46,15 @@
filled (eg. not None). Returns false (means the exception
shouldn't be suppressed).
"""
- pass
+ if exc_type is not None:
+ self.__actions.reverse()
+ for action in self.__actions:
+ action()
+ self.__actions = []
+ return False
def add(self, action):
"""
Records another rollback action.
"""
- pass
+ self.__actions.append(action)
More information about the bind10-changes
mailing list