Skip to content

Use new app.teardown_appcontext #7

Merged
merged 1 commit into from May 10, 2012
+7 −1
View
8 flaskext/mongokit.py
@@ -115,8 +115,14 @@ def init_app(self, app):
app.config.setdefault('MONGODB_PASSWORD', None)
app.before_request(self.before_request)
- if hasattr(app, 'teardown_request'):
+
+ # 0.9 and later
+ if hasattr(app, 'teardown_appcontext'):
+ app.teardown_appcontext(self.teardown_request)
+ # 0.7 to 0.8
+ elif hasattr(app, 'teardown_request'):
app.teardown_request(self.teardown_request)
+ # Older Flask versions
else:
app.after_request(self.teardown_request)
Something went wrong with that request. Please try again.