Changeset - 8e59d3d66159
[Not reviewed]
0 1 0
Joar Wandborg - 10 years ago 2013-12-17 10:16:51
joar@wandborg.se
[sql] Late init_app of SQLAlchemy

in order to be able to run sql/models.py alone (e.g. sphinx autodoc)
1 file changed with 5 insertions and 6 deletions:
0 comments (0 inline, 0 general)
accounting/storage/sql/__init__.py
Show inline comments
...
 
@@ -10,3 +10,3 @@ from accounting.models import Transaction, Posting, Amount
 
_log = logging.getLogger(__name__)
 
db = None
 
db = SQLAlchemy()
 

	
...
 
@@ -15,3 +15,2 @@ class SQLStorage(Storage):
 
    def __init__(self, app=None):
 
        global db
 

	
...
 
@@ -21,3 +20,3 @@ class SQLStorage(Storage):
 
        self.app = app
 
        db = self.db = SQLAlchemy(app)
 
        db.init_app(app)
 

	
...
 
@@ -71,3 +70,3 @@ class SQLStorage(Storage):
 

	
 
        self.db.session.add(_t)
 
        db.session.add(_t)
 

	
...
 
@@ -81,4 +80,4 @@ class SQLStorage(Storage):
 

	
 
            self.db.session.add(_p)
 
            db.session.add(_p)
 

	
 
        self.db.session.commit()
 
        db.session.commit()
0 comments (0 inline, 0 general)