Commit ca39a5e1 authored by Serge S. Koval's avatar Serge S. Koval Committed by GitHub

Merge pull request #1388 from pawl/remove_speakeasy_requirement

prevent AjaxSelectField autoflush while populating model
parents d84945cf 8bc5e9cd
......@@ -20,8 +20,7 @@ app.config['SECRET_KEY'] = '123456790'
app.config['DATABASE_FILE'] = 'sample_db.sqlite'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + app.config['DATABASE_FILE']
app.config['SQLALCHEMY_ECHO'] = True
session_options = dict(autoflush=False)
db = SQLAlchemy(app, session_options=session_options)
db = SQLAlchemy(app)
# Create models
......
......@@ -55,6 +55,8 @@ class QueryAjaxModelLoader(AjaxModelLoader):
return (getattr(model, self.pk), as_unicode(model))
def get_one(self, pk):
# prevent autoflush from occuring during populate_obj
with self.session.no_autoflush:
return self.session.query(self.model).get(pk)
def get_list(self, term, offset=0, limit=DEFAULT_PAGE_SIZE):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment