Added named parameters to avoid legacy parameter.

This commit is contained in:
Michele Comitini
2012-03-10 21:14:39 +01:00
parent ead5f57d26
commit cf0b40eaba
+18 -5
View File
@@ -50,9 +50,12 @@ class OAuthAccount(object):
AUTH_URL="https://graph.facebook.com/oauth/authorize" AUTH_URL="https://graph.facebook.com/oauth/authorize"
TOKEN_URL="https://graph.facebook.com/oauth/access_token" TOKEN_URL="https://graph.facebook.com/oauth/access_token"
def __init__(self, g): def __init__(self):
OAuthAccount.__init__(self, g, CLIENT_ID, CLIENT_SECRET, OAuthAccount.__init__(self,
self.AUTH_URL, self.TOKEN_URL, client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
auth_url=self.AUTH_URL,
token_url=self.TOKEN_URL,
scope='user_photos,friends_photos') scope='user_photos,friends_photos')
self.graph = None self.graph = None
@@ -81,6 +84,8 @@ class OAuthAccount(object):
username = user['id']) username = user['id'])
auth.settings.actions_disabled=['register','change_password','request_reset_password','profile']
auth.settings.login_form=FaceBookAccount()
Any optional arg in the constructor will be passed asis to remote Any optional arg in the constructor will be passed asis to remote
server for requests. It can be used for the optional"scope" parameters for Facebook. server for requests. It can be used for the optional"scope" parameters for Facebook.
@@ -176,11 +181,19 @@ server for requests. It can be used for the optional"scope" parameters for Face
current.session.token = None current.session.token = None
return None return None
def __init__(self, g, def __init__(self, g=None,
client_id, client_secret, auth_url, token_url, **args): client_id=None, client_secret=None,
auth_url=None, token_url=None, **args):
""" """
first argument is unused. Here only for legacy reasons. first argument is unused. Here only for legacy reasons.
""" """
if [client_id, client_secret, auth_url, token_url].count(None) > 0:
raise RuntimeError("""Following args are mandatory:
client_id,
client_secret,
auth_url,
token_url.
""")
self.client_id = client_id self.client_id = client_id
self.client_secret = client_secret self.client_secret = client_secret
self.auth_url = auth_url self.auth_url = auth_url