Merge 88722c72da
into fce1bb95e7
This commit is contained in:
commit
c18cdb74ec
|
@ -88,9 +88,11 @@ class SQLitePlugin(object):
|
|||
if bottle.__version__.startswith('0.9'):
|
||||
config = route['config']
|
||||
_callback = route['callback']
|
||||
argspec = inspect.getargspec(_callback).args
|
||||
else:
|
||||
config = route.config
|
||||
_callback = route.callback
|
||||
argspec = route.get_callback_args()
|
||||
|
||||
# Override global configuration with route-specific values.
|
||||
if "sqlite" in config:
|
||||
|
@ -109,10 +111,7 @@ class SQLitePlugin(object):
|
|||
collations = g('collations', self.collations)
|
||||
extensions = g('extensions', self.extensions)
|
||||
|
||||
# Test if the original callback accepts a 'db' keyword.
|
||||
# Ignore it if it does not need a database handle.
|
||||
argspec = inspect.getargspec(_callback)
|
||||
if keyword not in argspec.args:
|
||||
if keyword not in argspec:
|
||||
return callback
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
|
|
7
test.py
7
test.py
|
@ -28,6 +28,13 @@ class SQLiteTest(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
os.unlink(self.plugin.dbfile)
|
||||
|
||||
def test_with_view(self):
|
||||
@self.app.get('/')
|
||||
@bottle.view('test_view')
|
||||
def test(db):
|
||||
self.assertEqual(type(db), type(sqlite3.connect(':memory:')))
|
||||
self._request('/')
|
||||
|
||||
def test_with_keyword(self):
|
||||
@self.app.get('/')
|
||||
def test(db):
|
||||
|
|
1
views/test_view.tpl
Normal file
1
views/test_view.tpl
Normal file
|
@ -0,0 +1 @@
|
|||
test_view
|
Loading…
Reference in New Issue
Block a user