def user_update(context, data_dict):
 model = context['model']
 user = context['user']
 session = context['session']
 schema = (context.get('schema') or schema_.default_update_user_schema())
 id = _get_or_bust(data_dict, 'id')
 user_obj = model.User.get(id)
 context['user_obj'] = user_obj
 if (user_obj is None):
  raise NotFound('User was not found.')
 _check_access('user_update', context, data_dict)
 (data, errors) = _validate(data_dict, schema, context)
 if errors:
  session.rollback()
  raise ValidationError(errors)
 if ('password_hash' in data):
  data['_password'] = data.pop('password_hash')
 user = model_save.user_dict_save(data, context)
 activity_dict = {'user_id': user.id, 'object_id': user.id, 'activity_type': 'changed user'}
 activity_create_context = {'model': model, 'user': user, 'defer_commit': True, 'ignore_auth': True, 'session': session}
 _get_action('activity_create')(activity_create_context, activity_dict)
 if (not context.get('defer_commit')):
  model.repo.commit()
 return model_dictize.user_dictize(user, context)

def user_update ( context , data_dict ) : model = context [ 'model' ] user = context [ 'user' ] session = context [ 'session' ] schema = ( context . get ( 'schema' ) or schema_ . default_update_user_schema ( ) ) id = _get_or_bust ( data_dict , 'id' ) user_obj = model . User . get ( id ) context [ 'user_obj' ] = user_obj if ( user_obj is None ) : raise NotFound ( 'User was not found.' ) _check_access ( 'user_update' , context , data_dict ) ( data , errors ) = _validate ( data_dict , schema , context ) if errors : session . rollback ( ) raise ValidationError ( errors ) if ( 'password_hash' in data ) : data [ '_password' ] = data . pop ( 'password_hash' ) user = model_save . user_dict_save ( data , context ) activity_dict = { 'user_id' : user . id , 'object_id' : user . id , 'activity_type' : 'changed user' } activity_create_context = { 'model' : model , 'user' : user , 'defer_commit' : True , 'ignore_auth' : True , 'session' : session } _get_action ( 'activity_create' ) ( activity_create_context , activity_dict ) if ( not context . get ( 'defer_commit' ) ) : model . repo . commit ( ) return model_dictize . user_dictize ( user , context )
update a user account .