From 76da42522e971ecedb486552db9f4cb338f62c71 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Wed, 10 Nov 2010 19:49:21 +0000 Subject: [PATCH] Bug #634165: Better dealing with a locked database in python Patch by Christoph Holtermann: For the second enhancement proposal i have attached a simple patch which adds the argument ignore_lock to Session.__init__() which is passed through to qof_session_begin. This patch extends the function Session.__init__() with ignore_lock git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19795 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/optional/python-bindings/gnucash_core.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/optional/python-bindings/gnucash_core.py b/src/optional/python-bindings/gnucash_core.py index 6c09f21a7a..32b4f36efd 100644 --- a/src/optional/python-bindings/gnucash_core.py +++ b/src/optional/python-bindings/gnucash_core.py @@ -63,7 +63,7 @@ class Session(GnuCashCoreClass): Invoice..) is associated with a particular book where it is stored. """ - def __init__(self, book_uri=None, is_new=False): + def __init__(self, book_uri=None, is_new=False, ignore_lock=False): """A convienent contructor that allows you to specify a book URI, begin the session, and load the book. @@ -78,6 +78,8 @@ class Session(GnuCashCoreClass): is_new is passed to qof_session_begin as the argument create_if_nonexistent + ignore_lock is passed to qof_session + This function can raise a GnuCashBackendException. If it does, you don't need to cleanup and call end() and destroy(), that is handled for you, and the exception is raised. @@ -85,7 +87,7 @@ class Session(GnuCashCoreClass): GnuCashCoreClass.__init__(self) if book_uri is not None: try: - self.begin(book_uri, False, is_new) + self.begin(book_uri, ignore_lock, is_new) if not is_new: self.load() except GnuCashBackendException, backend_exception: