Created
January 13, 2013 21:38
-
-
Save shreyansb/4526331 to your computer and use it in GitHub Desktop.
#golang style errors in python. like it so far.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/<user_id>/facebook_id", methods=["PUT"]) | |
def put_facebook_id(user_id): | |
fb_d, err = get_facebook_data_from_cookie(request) | |
if err: | |
return json_error(err) | |
else: | |
# save and return success | |
pass | |
def get_facebook_data_from_cookie(request): | |
c_name = "fbsr_%s" % settings.FACEBOOK_APP_ID | |
c = request.cookies.get(c_name) | |
if not c: | |
return {}, "no facebook cookie in request" | |
d, err = validate_signed_request(c) | |
if err: | |
return {}, "invalid facebook signed_request" | |
else: | |
return d, None | |
def json_error(msg): | |
return json.dumps({'error': msg}), 400 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment