From 65e186de9b9c2b5edf923fadd598d161ec53a0ba Mon Sep 17 00:00:00 2001 From: Benoit Masson Date: Mon, 9 Jan 2017 01:41:03 +0100 Subject: [PATCH] Added a code to get into 1st level of closure in case of other decorator (like views) has wrapped the function and miss the the keyword detection. tested 0.12 & 0.13. --- bottle_sqlite.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bottle_sqlite.py b/bottle_sqlite.py index c4014a9..a6e5388 100755 --- a/bottle_sqlite.py +++ b/bottle_sqlite.py @@ -104,7 +104,17 @@ class SQLitePlugin(object): # Ignore it if it does not need a database handle. argspec = inspect.getargspec(_callback) if keyword not in argspec.args: - return callback + #check for closure + no_keyword_arg = True + for closure in _callback.func_closure: + contents = closure.cell_contents + if callable(contents): + argspec = inspect.getargspec(contents) + if keyword in argspec.args: + no_keyword_arg = False + break + if no_keyword_arg: + return callback def wrapper(*args, **kwargs): # Connect to the database