(self, ctx)
| 664 | ctx = property(_getctx) |
| 665 | |
| 666 | def _load_context(self, ctx): |
| 667 | ctx.dbq_count = 0 |
| 668 | ctx.transactions = [] # stack of transactions |
| 669 | |
| 670 | if self.has_pooling: |
| 671 | ctx.db = self._connect_with_pooling(self.keywords) |
| 672 | else: |
| 673 | ctx.db = self._connect(self.keywords) |
| 674 | ctx.db_execute = self._db_execute |
| 675 | |
| 676 | if not hasattr(ctx.db, "commit"): |
| 677 | ctx.db.commit = lambda: None |
| 678 | |
| 679 | if not hasattr(ctx.db, "rollback"): |
| 680 | ctx.db.rollback = lambda: None |
| 681 | |
| 682 | def commit(unload=True): |
| 683 | # do db commit and release the connection if pooling is enabled. |
| 684 | ctx.db.commit() |
| 685 | if unload and self.has_pooling: |
| 686 | self._unload_context(self._ctx) |
| 687 | |
| 688 | def rollback(): |
| 689 | # do db rollback and release the connection if pooling is enabled. |
| 690 | ctx.db.rollback() |
| 691 | if self.has_pooling: |
| 692 | self._unload_context(self._ctx) |
| 693 | |
| 694 | ctx.commit = commit |
| 695 | ctx.rollback = rollback |
| 696 | |
| 697 | def _unload_context(self, ctx): |
| 698 | del ctx.db |
no test coverage detected