{"action":"created","issue":{"url":"https://api.github.com/repos/bottlepy/bottle/issues/739","labels_url":"https://api.github.com/repos/bottlepy/bottle/issues/739/labels{/name}","comments_url":"https://api.github.com/repos/bottlepy/bottle/issues/739/comments","events_url":"https://api.github.com/repos/bottlepy/bottle/issues/739/events","html_url":"https://github.com/bottlepy/bottle/pull/739","id":63541315,"number":739,"title":".get_undecorated_callback() bugfix","user":{"login":"Bystroushaak","id":227282,"avatar_url":"https://avatars.githubusercontent.com/u/227282?v=3","gravatar_id":"","url":"https://api.github.com/users/Bystroushaak","html_url":"https://github.com/Bystroushaak","followers_url":"https://api.github.com/users/Bystroushaak/followers","following_url":"https://api.github.com/users/Bystroushaak/following{/other_user}","gists_url":"https://api.github.com/users/Bystroushaak/gists{/gist_id}","starred_url":"https://api.github.com/users/Bystroushaak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bystroushaak/subscriptions","organizations_url":"https://api.github.com/users/Bystroushaak/orgs","repos_url":"https://api.github.com/users/Bystroushaak/repos","events_url":"https://api.github.com/users/Bystroushaak/events{/privacy}","received_events_url":"https://api.github.com/users/Bystroushaak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-03-22T15:04:43Z","updated_at":"2015-03-23T10:34:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bottlepy/bottle/pulls/739","html_url":"https://github.com/bottlepy/bottle/pull/739","diff_url":"https://github.com/bottlepy/bottle/pull/739.diff","patch_url":"https://github.com/bottlepy/bottle/pull/739.patch"},"body":"I've found obscure error triggered in case of decorators with multiple parameters.\r\n\r\nNow, the ``.get_undecorated_callback()`` method just picks first attribute, which doesn't have to be function, but also one of the parameters of decorator with multiple parameters.\r\n\r\nFor example, this decorator will trigger the bug:\r\n\r\n```python\r\ndef database_decorator(fn=None, filename=\"default.sqlite\", table=\"default\"):\r\n    \"\"\"\r\n    Open connection to the database and offer it to the wrapped function.\r\n\r\n    So far, there is no database, only primitive JSON load/store system.\r\n    \"\"\"\r\n    def database_decorator_wrapper(fn):\r\n        @wraps(fn)\r\n        def database_wrapper(*args, **kwargs):\r\n            path = filename\r\n            if not os.path.isabs(path):\r\n                path = os.path.join(settings.DATABASE_PATH, path)\r\n\r\n            # load database\r\n            db = SqliteDict(\r\n                path,\r\n                # autocommit=True\r\n            )\r\n\r\n            # load table\r\n            table_ref = db.get(table, {})\r\n\r\n            # put table to function parameters\r\n            kwargs[\"db\"] = table_ref\r\n\r\n            out = fn(*args, **kwargs)\r\n\r\n            # save database\r\n            db[table] = table_ref\r\n            db.commit()\r\n\r\n            return out\r\n\r\n        return database_wrapper\r\n\r\n    if fn:  # python decorator with optional parameters bukkake\r\n        return database_decorator_wrapper(fn)\r\n\r\n    return database_decorator_wrapper\r\n```\r\n\r\nMy patch just looks for cases when the ``func`` is not ``FunctionType`` instance (which it should be) and then goes thru all the parameters and pick first ``FunctionType`` instance."},"comment":{"url":"https://api.github.com/repos/bottlepy/bottle/issues/comments/84938553","html_url":"https://github.com/bottlepy/bottle/pull/739#issuecomment-84938553","issue_url":"https://api.github.com/repos/bottlepy/bottle/issues/739","id":84938553,"user":{"login":"Bystroushaak","id":227282,"avatar_url":"https://avatars.githubusercontent.com/u/227282?v=3","gravatar_id":"","url":"https://api.github.com/users/Bystroushaak","html_url":"https://github.com/Bystroushaak","followers_url":"https://api.github.com/users/Bystroushaak/followers","following_url":"https://api.github.com/users/Bystroushaak/following{/other_user}","gists_url":"https://api.github.com/users/Bystroushaak/gists{/gist_id}","starred_url":"https://api.github.com/users/Bystroushaak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bystroushaak/subscriptions","organizations_url":"https://api.github.com/users/Bystroushaak/orgs","repos_url":"https://api.github.com/users/Bystroushaak/repos","events_url":"https://api.github.com/users/Bystroushaak/events{/privacy}","received_events_url":"https://api.github.com/users/Bystroushaak/received_events","type":"User","site_admin":false},"created_at":"2015-03-23T10:34:38Z","updated_at":"2015-03-23T10:34:38Z","body":"The bug shows only when I use kwargs."}}