equal
deleted
inserted
replaced
105 self._pendingcallback = {} |
105 self._pendingcallback = {} |
106 # True is any pending data have been written ever |
106 # True is any pending data have been written ever |
107 self._anypending = False |
107 self._anypending = False |
108 # holds callback to call when writing the transaction |
108 # holds callback to call when writing the transaction |
109 self._finalizecallback = {} |
109 self._finalizecallback = {} |
|
110 # hold callbalk for post transaction close |
|
111 self._postclosecallback = {} |
110 |
112 |
111 def __del__(self): |
113 def __del__(self): |
112 if self.journal: |
114 if self.journal: |
113 self._abort() |
115 self._abort() |
114 |
116 |
297 newer callbacks. |
299 newer callbacks. |
298 """ |
300 """ |
299 self._finalizecallback[category] = callback |
301 self._finalizecallback[category] = callback |
300 |
302 |
301 @active |
303 @active |
|
304 def addpostclose(self, category, callback): |
|
305 """add a callback to be called after the transaction is closed |
|
306 |
|
307 Category is a unique identifier to allow overwriting an old callback |
|
308 with a newer callback. |
|
309 """ |
|
310 self._postclosecallback[category] = callback |
|
311 |
|
312 @active |
302 def close(self): |
313 def close(self): |
303 '''commit the transaction''' |
314 '''commit the transaction''' |
304 if self.count == 1 and self.onclose is not None: |
315 if self.count == 1 and self.onclose is not None: |
305 self._generatefiles() |
316 self._generatefiles() |
306 categories = sorted(self._finalizecallback) |
317 categories = sorted(self._finalizecallback) |
322 self.opener.unlink(self.backupjournal) |
333 self.opener.unlink(self.backupjournal) |
323 for _f, b, _ignore in self.backupentries: |
334 for _f, b, _ignore in self.backupentries: |
324 self.opener.unlink(b) |
335 self.opener.unlink(b) |
325 self.backupentries = [] |
336 self.backupentries = [] |
326 self.journal = None |
337 self.journal = None |
|
338 # run post close action |
|
339 categories = sorted(self._postclosecallback) |
|
340 for cat in categories: |
|
341 self._postclosecallback[cat]() |
327 |
342 |
328 @active |
343 @active |
329 def abort(self): |
344 def abort(self): |
330 '''abort the transaction (generally called on error, or when the |
345 '''abort the transaction (generally called on error, or when the |
331 transaction is not explicitly committed before going out of |
346 transaction is not explicitly committed before going out of |