Skip to content

Commit 67b251e

Browse files
authored
Merge pull request #152 from gisce/context_cursor_push_at_transaction_start
Push/pop cursor to context stack at transaction start/stop
2 parents d78e618 + 0a0a285 commit 67b251e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

destral/openerp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ def __init__(self, **kwargs):
3636
if hasattr(tools.config, 'parse'):
3737
tools.config.parse()
3838
from tools import config as default_config
39+
from ctx import _cursor_context
3940
self.config = update_config(default_config, **config)
4041
import pooler
4142
import workflow
4243
self.pooler = pooler
4344
self.db = None
4445
self.pool = None
46+
self.cursor_stack = _cursor_context
4547
if 'db_name' in config:
4648
try:
4749
self.db_name = config['db_name']

destral/transaction.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def start(self, database_name, user=1, context=None):
4747
self.service = OpenERPService(db_name=database_name)
4848
self.pool = self.service.pool
4949
self.cursor = self.service.db.cursor()
50+
self.service.cursor_stack.push(self.cursor)
5051
self.user = user
5152
try:
5253
receivers = DB_CURSOR_EXECUTE.receivers
@@ -60,6 +61,7 @@ def stop(self):
6061
"""Stop the transaction.
6162
"""
6263
if self.cursor is not None:
64+
self.service.cursor_stack.pop()
6365
self.cursor.close()
6466
self.service = None
6567
self.cursor = None

0 commit comments

Comments
 (0)