def user_name_validator(key, data, errors, context):
 model = context['model']
 new_user_name = data[key]
 if (not isinstance(new_user_name, basestring)):
  raise Invalid(_('User names must be strings'))
 user = model.User.get(new_user_name)
 if (user is not None):
  user_obj_from_context = context.get('user_obj')
  if (user_obj_from_context and (user_obj_from_context.id == user.id)):
   return
  else:
   errors[key].append(_('That login name is not available.'))

def user_name_validator ( key , data , errors , context ) : model = context [ 'model' ] new_user_name = data [ key ] if ( not isinstance ( new_user_name , basestring ) ) : raise Invalid ( _ ( 'User names must be strings' ) ) user = model . User . get ( new_user_name ) if ( user is not None ) : user_obj_from_context = context . get ( 'user_obj' ) if ( user_obj_from_context and ( user_obj_from_context . id == user . id ) ) : return else : errors [ key ] . append ( _ ( 'That login name is not available.' ) )
validate a new user name .