Esempio n. 1
0
def save_fb_user(content):
	"""
		Internal dao method to save/update an fb user
	"""
	res = {}
	res['valid'] = False
	try:
		user = User()
		user.userid = content['id']
		user.firstname = content['first_name'] if 'first_name' in content else None
		user.lastname = content['last_name'] if 'last_name' in content else None
		user.email = content['email'] if 'email' in content else None
		user.birthday = datetime.strptime(content['birthday'], '%m/%d/%Y') if 'birthday' in content else None
		user.gender = content['gender']  if 'gender' in content else None
		user.access_token = content['access_token']
		user.location = update_fb_user_location(content['location']) if 'location' in content else None
		user.save()	
		res['valid'] = True
		res['userid'] = content['id']
		res['access_token'] = content['access_token']
	except:
		logger.exception("Unexpected error while saving user: "+str(sys.exc_info()[0]))
		res['valid'] = False
		return res
	return res