File tree Expand file tree Collapse file tree 1 file changed +11
-23
lines changed Expand file tree Collapse file tree 1 file changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -41,32 +41,20 @@ def rollback(self):
4141 a_state ()
4242
4343
44- class Transactional :
44+ def Transactional ( method ) :
4545 """Adds transactional semantics to methods. Methods decorated with
46+ @Transactional will roll back to entry-state upon exceptions.
4647
47- @Transactional will rollback to entry-state upon exceptions .
48+ :param method: The function to be decorated .
4849 """
49-
50- def __init__ (self , method ):
51- self .method = method
52-
53- def __get__ (self , obj , T ):
54- """
55- A decorator that makes a function transactional.
56-
57- :param method: The function to be decorated.
58- """
59-
60- def transaction (* args , ** kwargs ):
61- state = memento (obj )
62- try :
63- return self .method (obj , * args , ** kwargs )
64- except Exception as e :
65- state ()
66- raise e
67-
68- return transaction
69-
50+ def transaction (obj , * args , ** kwargs ):
51+ state = memento (obj )
52+ try :
53+ return method (obj , * args , ** kwargs )
54+ except Exception as e :
55+ state ()
56+ raise e
57+ return transaction
7058
7159class NumObj :
7260 def __init__ (self , value ):
You can’t perform that action at this time.
0 commit comments