def update_user_attributes(user, profile, attributes_dict, save=False):
 profile_fields = []
 if profile:
  profile_fields = [f.name for f in profile._meta.fields]
 user_fields = [f.name for f in user._meta.fields]
 is_profile_field = (lambda f: ((f in profile_fields) and hasattr(profile, f)))
 is_user_field = (lambda f: ((f in user_fields) and hasattr(user, f)))
 for (f, value) in attributes_dict.items():
  if is_profile_field(f):
   setattr(profile, f, value)
   profile._fb_is_dirty = True
  elif is_user_field(f):
   setattr(user, f, value)
   user._fb_is_dirty = True
  else:
   logger.info('skipping update of field %s', f)
 if save:
  if getattr(user, '_fb_is_dirty', False):
   user.save()
  if (profile and getattr(profile, '_fb_is_dirty', False)):
   profile.save()

def update_user_attributes ( user , profile , attributes_dict , save = False ) : profile_fields = [ ] if profile : profile_fields = [ f . name for f in profile . _meta . fields ] user_fields = [ f . name for f in user . _meta . fields ] is_profile_field = ( lambda f : ( ( f in profile_fields ) and hasattr ( profile , f ) ) ) is_user_field = ( lambda f : ( ( f in user_fields ) and hasattr ( user , f ) ) ) for ( f , value ) in attributes_dict . items ( ) : if is_profile_field ( f ) : setattr ( profile , f , value ) profile . _fb_is_dirty = True elif is_user_field ( f ) : setattr ( user , f , value ) user . _fb_is_dirty = True else : logger . info ( 'skipping update of field %s' , f ) if save : if getattr ( user , '_fb_is_dirty' , False ) : user . save ( ) if ( profile and getattr ( profile , '_fb_is_dirty' , False ) ) : profile . save ( )
write the attributes either to the user or profile instance .