rdegges / flask-dynamo

DynamoDB integration for Flask.
http://flask-dynamo.readthedocs.org/en/latest/
The Unlicense
141 stars 36 forks source link

manager.Dynamo.init_app #29

Closed tcco closed 7 years ago

tcco commented 7 years ago

So I bumped to 0.1.1 and am running into the RuntimeError from _get_app when calling self.connection in init_app. It breaks since current_app and self.app do not return. Current app is not set since this is at load time. My question however is if self.app should be set in init_app?

My config

common/
    dynamo = flask_dynamo.Dynamo()

app.py
    dynamo.init_app(app)
jaustinpage commented 7 years ago

Hey, i'm taking a look now. Thanks for the report!

jaustinpage commented 7 years ago

Hey, I am able to reproduce. I will get a fix put together asap.

tcco commented 7 years ago

awesome, barring any unintended consequences I tested with just adding self.app into the init_app and it seemed to work.

jaustinpage commented 7 years ago

yeah, you really dont want to do that. it means that the dynamo object is now tied directly to the app instance, regardless of what the flask app context proxy is. it breaks the app factory magic. While you can get away with it on a small scale, if you start creating multiple apps using the app factory pattern, it can get confused. Im almost done writing tests to catch this in the future.

jaustinpage commented 7 years ago

Ok, i think i got it fixed now.

tcco commented 7 years ago

understood and perfect thanks @jaustinpage

jaustinpage commented 7 years ago

so the branch is working for you?

tcco commented 7 years ago

The branch is working for me thanks! Closing out now

jaustinpage commented 7 years ago

https://pypi.python.org/pypi/flask-dynamo v0.1.2 is up, and includes the fix. Sorry for the bug, and thanks for reporting it!