Show More
@@ -105,6 +105,8 class transaction(object): | |||
|
105 | 105 | self._pendingcallback = {} |
|
106 | 106 | # True is any pending data have been written ever |
|
107 | 107 | self._anypending = False |
|
108 | # holds callback to call when writing the transaction | |
|
109 | self._finalizecallback = {} | |
|
108 | 110 | |
|
109 | 111 | def __del__(self): |
|
110 | 112 | if self.journal: |
@@ -288,10 +290,22 class transaction(object): | |||
|
288 | 290 | return self._anypending |
|
289 | 291 | |
|
290 | 292 | @active |
|
293 | def addfinalize(self, category, callback): | |
|
294 | """add a callback to be called when the transaction is closed | |
|
295 | ||
|
296 | Category is a unique identifier to allow overwriting old callbacks with | |
|
297 | newer callbacks. | |
|
298 | """ | |
|
299 | self._finalizecallback[category] = callback | |
|
300 | ||
|
301 | @active | |
|
291 | 302 | def close(self): |
|
292 | 303 | '''commit the transaction''' |
|
293 | 304 | if self.count == 1 and self.onclose is not None: |
|
294 | 305 | self._generatefiles() |
|
306 | categories = sorted(self._finalizecallback) | |
|
307 | for cat in categories: | |
|
308 | self._finalizecallback[cat]() | |
|
295 | 309 | self.onclose() |
|
296 | 310 | |
|
297 | 311 | self.count -= 1 |
General Comments 0
You need to be logged in to leave comments.
Login now