File tree Expand file tree Collapse file tree 2 files changed +6
-11
lines changed Expand file tree Collapse file tree 2 files changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ Other changes in this release:
39
39
* Add the attribute name to error messages when deserialization fails (#815)
40
40
* Add the table name to error messages for transactional operations (#835)
41
41
* Move ``pynamodb.connection.util.pythonic `` to ``pynamodb.util.snake_to_camel_case `` (#753)
42
+ * Remove ``ModelContextManager `` class (#861)
42
43
43
44
Contributors to this release:
44
45
Original file line number Diff line number Diff line change 44
44
log .addHandler (logging .NullHandler ())
45
45
46
46
47
- class ModelContextManager (Generic [_T ]):
47
+ class BatchWrite (Generic [_T ]):
48
48
"""
49
- A class for managing batch operations
49
+ A class for batch writes
50
50
"""
51
-
52
51
def __init__ (self , model : Type [_T ], auto_commit : bool = True ):
53
52
self .model = model
54
53
self .auto_commit = auto_commit
55
54
self .max_operations = BATCH_WRITE_PAGE_LIMIT
56
55
self .pending_operations : List [Dict [str , Any ]] = []
57
56
self .failed_operations : List [Any ] = []
58
57
59
- def __enter__ (self ):
60
- return self
61
-
62
-
63
- class BatchWrite (ModelContextManager , Generic [_T ]):
64
- """
65
- A class for batch writes
66
- """
67
58
def save (self , put_item : _T ) -> None :
68
59
"""
69
60
This adds `put_item` to the list of pending operations to be performed.
@@ -104,6 +95,9 @@ def delete(self, del_item: _T) -> None:
104
95
self .commit ()
105
96
self .pending_operations .append ({"action" : DELETE , "item" : del_item })
106
97
98
+ def __enter__ (self ):
99
+ return self
100
+
107
101
def __exit__ (self , exc_type , exc_val , exc_tb ):
108
102
"""
109
103
This ensures that all pending operations are committed when
You can’t perform that action at this time.
0 commit comments