Skip to content

Commit

Permalink
Merge pull request #152 from gisce/context_cursor_push_at_transaction…
Browse files Browse the repository at this point in the history
…_start

Push/pop cursor to context stack at transaction start/stop
  • Loading branch information
polsala authored Jun 11, 2024
2 parents d78e618 + 0a0a285 commit 67b251e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions destral/openerp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ def __init__(self, **kwargs):
if hasattr(tools.config, 'parse'):
tools.config.parse()
from tools import config as default_config
from ctx import _cursor_context
self.config = update_config(default_config, **config)
import pooler
import workflow
self.pooler = pooler
self.db = None
self.pool = None
self.cursor_stack = _cursor_context
if 'db_name' in config:
try:
self.db_name = config['db_name']
Expand Down
2 changes: 2 additions & 0 deletions destral/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def start(self, database_name, user=1, context=None):
self.service = OpenERPService(db_name=database_name)
self.pool = self.service.pool
self.cursor = self.service.db.cursor()
self.service.cursor_stack.push(self.cursor)
self.user = user
try:
receivers = DB_CURSOR_EXECUTE.receivers
Expand All @@ -60,6 +61,7 @@ def stop(self):
"""Stop the transaction.
"""
if self.cursor is not None:
self.service.cursor_stack.pop()
self.cursor.close()
self.service = None
self.cursor = None
Expand Down

0 comments on commit 67b251e

Please sign in to comment.