Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #653 from methane/patch-1

docs/extensiondev: Use `current_app` instead of `self.app`
  • Loading branch information...
commit dfdbc00eafb3e7578b81f82a59630f2e79691cee 2 parents 7ec45c2 + be0b519
@mitsuhiko authored
Showing with 4 additions and 5 deletions.
  1. +4 −5 docs/extensiondev.rst
View
9 docs/extensiondev.rst
@@ -165,6 +165,7 @@ The Extension Code
Here's the contents of the `flask_sqlite3.py` for copy/paste::
import sqlite3
+ from flask import current_app
# Find the stack on which we want to store the database connection.
# Starting with Flask 0.9, the _app_ctx_stack is the correct one,
@@ -178,11 +179,9 @@ Here's the contents of the `flask_sqlite3.py` for copy/paste::
class SQLite3(object):
def __init__(self, app=None):
+ self.app = app
if app is not None:
- self.app = app
- self.init_app(self.app)
- else:
- self.app = None
+ self.init_app(app)
def init_app(self, app):
app.config.setdefault('SQLITE3_DATABASE', ':memory:')
@@ -194,7 +193,7 @@ Here's the contents of the `flask_sqlite3.py` for copy/paste::
app.teardown_request(self.teardown)
def connect(self):
- return sqlite3.connect(self.app.config['SQLITE3_DATABASE'])
+ return sqlite3.connect(current_app.config['SQLITE3_DATABASE'])
def teardown(self, exception):
ctx = stack.top
Please sign in to comment.
Something went wrong with that request. Please try again.