-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new mongomock commit breaks flask init #220
Comments
any update on this ? |
I stumbled upon this today as well. AFAIU, @ntcong's diagnosis is correct. Removing this line fixes it:
@losintikfos, can you explain the need to test for this? I mean, if the host starts with If there is any reason to test this, then @losintikfos, I know you're working on the connection part and you don't have much time for it. Should we
Thanks. |
@lafrech I will ensure Thanks. |
Hi @losintikfos. Congratulations for your work on the connection module. I don't know if you're done with it or not, but just in case, I thought I'd let you know I just tried latest master version of flask-mongoengine on my project and I still have this issue. It fails here:
|
@lafrech can you send me a test case to simulate here please. Ta! |
I think my original test still didn't work
It's still the same problem: you shouldn't use current_app when initialize an extension. The prefered way is passing an app instance |
@ntcong I having a look into this. Ta |
I trimmed down my use case to this: from flask import Flask
from flask_mongoengine import MongoEngine
class Config(object):
SECRET_KEY = ("whatever")
MONGODB_SETTINGS = {
'db': 'db',
'host': 'localhost',
'port': 27017,
'username': 'user',
'password': 'pwd'
}
me = MongoEngine()
def create_app(**kwargs):
app = Flask(__name__, **kwargs)
app.config.from_object(Config)
me.init_app(app)
return app
app = create_app() I think this use case (app factory) is less common. However, @ntcong's example is precisely the use case described in the docs, so I'm wondering which use case actually work. Anyway, thanks @losintikfos for investigating. |
This small code snippet won't work
I think because on _create_connection we don't have a app context yet. Init_app should take an app and get config from it, instead of using local app context.
Adding a parameter to _create_connection should be enough so I can do a PR if it's acceptable.
The text was updated successfully, but these errors were encountered: