-
Notifications
You must be signed in to change notification settings - Fork 177
Flask-PyMongo 2.0 #110
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
Comments
When in time do you see a version 2.0 being ready for testing? |
I hope to have an RC ready some time in June. Unlike with past releases, I'm planning to do at least one rc release before 2.0, to let folks have a chance to experiment with it and get some feedback. That might add another month to the cycle, just to ensure that we've had an adequate chance to find any major issues before cutting 2.0. |
For anyone interested in following along with development, I've started a branch https://github.com/dcrosta/flask-pymongo/tree/two-point-oh |
@hbldh and anyone else here, if you want to live on the bleeding bleeding edge, there's now a probably-working version on branch |
Very nice! I will try to test it in a few of my apps over the next few days. |
@hbldh it's on PyPI as a beta now (https://pypi.org/manage/project/Flask-PyMongo/release/2.0.0b1/) so Updated docs at https://flask-pymongo.readthedocs.io/en/2.0.0b1/ |
Hey @hbldh -- just wondering if you've had a chance to try 2.0 out, and if you have any feedback? |
I have now tried it out - at long last due to illness - in a few of my apps, and 2.0.0b1 works without any modification at all in my apps; a lovely feeling indeed! Since they are mostly deployed on Heroku, they were all provisioned by The code is commendably slim in my opinion. The only thing I have thought about is whether the Have you tried monkeypatching the true PyMongo Collection object with a |
Awesome, that's exciting good news! I split out Re: monkeypatching, I'd rather not. It probably could be done relatively safely, but it feels wrong, and the wrappers don't add any overhead other than in |
The However I remembered one thing: #87 is a very valid point, made by a MongoDB employee, and I think |
I'd like to hew as close as possible to PyMongo's defaults, so I don't think we should synthesize arguments (that was the whole point of 2.0, to stop doing that!), but since most people using Flask are probably using some kind of forking, I'll add a note to the documentation. |
(See d50af87) |
I understand your aim to not introduce any non-pymongo defaults and I think it is a very good idea, in general. However, given that this project caters to web applications and web applications have a tendency to run into this issue if a pre-fork server is used, I would like to argue that there is such a strong reason to have one exception to the "do not synthesize arguments" rule, namely Yes, adding it as a keyword argument in the creation of the Flask-PyMongo client is very simple, as is adding it to the URI. Having a note in the documentation about how to resolve potential issues is great, but just having it set to Anyway, at least I have made a plea for my case now. |
@ajdavis hoping you (or one of your co-worker more currently involved in PyMongo, perhaps?) can shed some light here -- a) is forking still an issue in modern versions of pymongo, and b) if it's problematic, why still do it (ie default to @hbldh I'm still pretty wary of going down the path of adding defaults. At minimum, I'd like to hear from some more users that this is causing problems or inconvenient for them before making a call here. |
a) Yes, forking is still an issue. It's basically impossible in any programming language including Python to design a class that starts threads and opens connections before a fork, and is still in a correct state afterward. (More info: PYTHON-1139, PYTHON-1348.) b) If we defaulted connect=False, that would help people who do exactly this:
But it doesn't save anyone who does this:
Since that's a bit subtle, we decided that our current connect=True default has a more reliable behavior: if you create a client before you fork, it warns you when you use it after the fork. The best solution IMO for all users is to create the client after the fork. However, if they pass connect=False and carefully avoid using the client before the fork then it will work. If you think that Flask-PyMongo users are likely to understand the distinction and will benefit from a better default, then defaulting connect=False here could be worthwhile. |
OK so I'm pretty convinced It looks like right now, keyword arguments take precedence over the same value specified as a param in the connection URL. Is that guaranteed always to be true? (ie if I say |
Keywords beat URL parameters until PyMongo 4.0 at least, since changing it would be a BC break. I think it's the right precedence anyway and will never change. |
Flask-PyMongo 2.0.0b2 now available on PyPI (install with |
I've just released Flask-PyMongo 2.0 to PyPI.org, so I'm closing this now. As always, please report any issues back here. |
TL;DR:
pip install --pre ...
; docs here)app.config["MONGO_URI"] = ...
)** If you don't have time to update your app to use a URI by then, pin down to version 0.5.2 in your requirements
Keeping up with PyMongo and MongoDB developments has been a continual struggle for me as maintainer of Flask-PyMongo, as attested to by the long list of bugs filed. I have let down those who use this project, and I apologize for that.
In order to make the maintenance load acceptable, I have decided to release version 2.0 which will remove all of the "split out" configuration functionality. In 2.0, Flask-PyMongo will only read a MongoDB connection URI from Flask config. For cases where some configuration cannot be passed via URI, it will also accept keyword arguments, which will be passed directly to PyMongo.
I anticipate that this will require changes from many users of Flask-PyMongo, and I apologize for the disruption. I believe that this direction will enable me to keep up with compatibility requests, reduce the number of custom forked versions, and provide a more compact and stable platform for future development.
If you have not yet done so, please pin your version of Flask-PyMongo to the current version (e.g.
flask-pymongo<2.0
in arequirements.txt
file).I will try to answer any questions that may come up in this thread until (and likely slightly after) the release of 2.0.
The text was updated successfully, but these errors were encountered: