File tree 1 file changed +11
-23
lines changed
1 file changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -41,32 +41,20 @@ def rollback(self):
41
41
a_state ()
42
42
43
43
44
- class Transactional :
44
+ def Transactional ( method ) :
45
45
"""Adds transactional semantics to methods. Methods decorated with
46
+ @Transactional will roll back to entry-state upon exceptions.
46
47
47
- @Transactional will rollback to entry-state upon exceptions .
48
+ :param method: The function to be decorated .
48
49
"""
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
70
58
71
59
class NumObj :
72
60
def __init__ (self , value ):
You can’t perform that action at this time.
0 commit comments