Skip to content

Commit

Permalink
fix flask-marshmallow factory pattern issue
Browse files Browse the repository at this point in the history
ma.init_app(app) replace DummySession() by db.session but its too late,
schemas have already been created, so replace it as soon as ma have been initialized.

marshmallow-code/flask-marshmallow#44
marshmallow-code/flask-marshmallow#74
marshmallow-code/flask-marshmallow#111
  • Loading branch information
bouttier committed Oct 17, 2022
1 parent 4ac6382 commit 5c641e8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/geonature/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
DB = db = SQLAlchemy()
os.environ["FLASK_MARSHMALLOW"] = "geonature.utils.env.ma"
MA = ma = Marshmallow()
ma.SQLAlchemySchema.OPTIONS_CLASS.session = db.session
ma.SQLAlchemyAutoSchema.OPTIONS_CLASS.session = db.session
os.environ["FLASK_MIGRATE"] = "geonature.utils.env.migrate"
migrate = Migrate()

Expand Down

0 comments on commit 5c641e8

Please sign in to comment.