Skip to content

Conversation

davislx
Copy link
Contributor

@davislx davislx commented Jan 8, 2014

Bug

The client/token getter and setters in oauth provider 1 & 2 makes the original function not callable

Reproduce

Steps:

from . import oauth  #the oauth server object
@oauth.grantgetter
def load_request_token(token):
     print 'abc'
     return 1

if __name__ == '__main__':
    load_request_token('cba')

Expectation:
Running the script will print out abc

Reality:
Won't be able to call load_request_token

Solution

Add return f to all the getter and setter in the providers

Reference

Flask's getter decorator also return the f:

@setupmethod
def before_request(self, f):
    """Registers a function to run before each request."""
    self.before_request_funcs.setdefault(None, []).append(f)
    return f

https://github.com/mitsuhiko/flask/blob/master/flask/app.py#L1194

Test result

(flask-oauthlib)davislx@vm-0:~/Github/flask-oauthlib$ nosetests                                                                                                                                              
..................................................................
----------------------------------------------------------------------
Ran 66 tests in 194.731s
OK

lepture added a commit that referenced this pull request Jan 9, 2014
Branch:dec - adding return statement to all the decorator func
@lepture lepture merged commit 54ef296 into lepture:master Jan 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants