Skip to content

Commit 93bd9b9

Browse files
authored
Merge pull request #401 from MongoEngine/init_app_config
Allow keep config in MongoEngine object until init_app
2 parents bcf79f6 + dc3bfe6 commit 93bd9b9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

flask_mongoengine/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def __init__(self, app=None, config=None):
9696
_include_mongoengine(self)
9797

9898
self.app = None
99+
self.config = config
99100
self.Document = Document
100101
self.DynamicDocument = DynamicDocument
101102

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

124-
if not config:
125-
# If not passed a config then we read the connection settings
126-
# from the app config.
125+
if config:
126+
# Passed config have max priority, over init config.
127+
self.config = config
128+
129+
if not self.config:
130+
# If no configs passed, use app.config.
127131
config = app.config
128132

129133
# Obtain db connection(s)

0 commit comments

Comments
 (0)