def group_id_or_name_exists(reference, context):
 model = context['model']
 result = model.Group.get(reference)
 if (not result):
  raise Invalid(_('That group name or ID does not exist.'))
 return reference

def group_id_or_name_exists ( reference , context ) : model = context [ 'model' ] result = model . Group . get ( reference ) if ( not result ) : raise Invalid ( _ ( 'That group name or ID does not exist.' ) ) return reference
raises invalid if a group identified by the name or id cannot be found .