Skip to content

Commit

Permalink
Merge pull request #401 from MongoEngine/init_app_config
Browse files Browse the repository at this point in the history
Allow keep config in MongoEngine object until init_app
  • Loading branch information
insspb authored Jun 8, 2020
2 parents bcf79f6 + dc3bfe6 commit 93bd9b9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions flask_mongoengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def __init__(self, app=None, config=None):
_include_mongoengine(self)

self.app = None
self.config = config
self.Document = Document
self.DynamicDocument = DynamicDocument

Expand All @@ -121,9 +122,12 @@ def init_app(self, app, config=None):
# potentially new configuration would not be loaded.
raise ValueError("Extension already initialized")

if not config:
# If not passed a config then we read the connection settings
# from the app config.
if config:
# Passed config have max priority, over init config.
self.config = config

if not self.config:
# If no configs passed, use app.config.
config = app.config

# Obtain db connection(s)
Expand Down

0 comments on commit 93bd9b9

Please sign in to comment.