def user_id_or_name_exists(user_id_or_name, context):
 model = context['model']
 session = context['session']
 result = session.query(model.User).get(user_id_or_name)
 if result:
  return user_id_or_name
 result = session.query(model.User).filter_by(name=user_id_or_name).first()
 if (not result):
  raise Invalid(('%s: %s' % (_('Not found'), _('User'))))
 return user_id_or_name

def user_id_or_name_exists ( user_id_or_name , context ) : model = context [ 'model' ] session = context [ 'session' ] result = session . query ( model . User ) . get ( user_id_or_name ) if result : return user_id_or_name result = session . query ( model . User ) . filter_by ( name = user_id_or_name ) . first ( ) if ( not result ) : raise Invalid ( ( '%s: %s' % ( _ ( 'Not found' ) , _ ( 'User' ) ) ) ) return user_id_or_name
return the given user_id_or_name if such a user exists .