diff --git a/examples/appengine/example.py b/examples/appengine/example.py index 95f021e..36bebf8 100644 --- a/examples/appengine/example.py +++ b/examples/appengine/example.py @@ -31,6 +31,7 @@ from google.appengine.ext.webapp import template from google.appengine.api.urlfetch import fetch + class User(db.Model): id = db.StringProperty(required=True) created = db.DateTimeProperty(auto_now_add=True) @@ -82,11 +83,12 @@ def get(self): self.response.out.write(template.render(path, args)) def post(self): - url=self.request.get('url') + url = self.request.get('url') file = urllib2.urlopen(url) graph = facebook.GraphAPI(self.current_user.access_token) graph.put_photo(file, "Test Image") + def main(): logging.getLogger().setLevel(logging.DEBUG) util.run_wsgi_app(webapp.WSGIApplication([(r"/", HomeHandler)])) diff --git a/examples/oauth/facebookoauth.py b/examples/oauth/facebookoauth.py index a5cc071..cb36b56 100644 --- a/examples/oauth/facebookoauth.py +++ b/examples/oauth/facebookoauth.py @@ -80,7 +80,8 @@ def get(self): class LoginHandler(BaseHandler): def get(self): verification_code = self.request.get("code") - args = dict(client_id=FACEBOOK_APP_ID, redirect_uri=self.request.path_url) + args = dict(client_id=FACEBOOK_APP_ID, + redirect_uri=self.request.path_url) if self.request.get("code"): args["client_secret"] = FACEBOOK_APP_SECRET args["code"] = self.request.get("code") @@ -121,7 +122,8 @@ def set_cookie(response, name, value, domain=None, path="/", expires=None): cookie = Cookie.BaseCookie() cookie[name] = "|".join([value, timestamp, signature]) cookie[name]["path"] = path - if domain: cookie[name]["domain"] = domain + if domain: + cookie[name]["domain"] = domain if expires: cookie[name]["expires"] = email.utils.formatdate( expires, localtime=False, usegmt=True) @@ -130,9 +132,11 @@ def set_cookie(response, name, value, domain=None, path="/", expires=None): def parse_cookie(value): """Parses and verifies a cookie value from set_cookie""" - if not value: return None + if not value: + return None parts = value.split("|") - if len(parts) != 3: return None + if len(parts) != 3: + return None if cookie_signature(parts[0], parts[1]) != parts[2]: logging.warning("Invalid cookie signature %r", value) return None @@ -153,7 +157,8 @@ def cookie_signature(*parts): people using this example don't accidentally all use the same secret). """ hash = hmac.new(FACEBOOK_APP_SECRET, digestmod=hashlib.sha1) - for part in parts: hash.update(part) + for part in parts: + hash.update(part) return hash.hexdigest() diff --git a/examples/tornado/example.py b/examples/tornado/example.py index 45da0a4..6eaa38b 100755 --- a/examples/tornado/example.py +++ b/examples/tornado/example.py @@ -44,7 +44,8 @@ def get_current_user(self): cookies = dict((n, self.cookies[n].value) for n in self.cookies.keys()) cookie = facebook.get_user_from_cookie( cookies, options.facebook_app_id, options.facebook_app_secret) - if not cookie: return None + if not cookie: + return None user = self.db.get( "SELECT * FROM users WHERE id = %s", cookie["uid"]) if not user: diff --git a/setup.py b/setup.py index cf4a311..a362c26 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,15 @@ #!/usr/bin/env python from distutils.core import setup - + setup( name='facebook-sdk', version='0.2.0', - description='This client library is designed to support the Facebook Graph API and the official Facebook JavaScript SDK, which is the canonical way to implement Facebook authentication.', + description='This client library is designed to support the Facebook ' + 'Graph API and the official Facebook JavaScript SDK, which ' + 'is the canonical way to implement Facebook authentication.', author='Facebook', url='http://github.com/pythonforfacebook/facebook-sdk', py_modules=[ 'facebook', ], ) -