'Field options introspection method (single table)
@param r: the S3Request instance
@param attr: controller attributes'

@staticmethod
def get_options(r, **attr):

    get_vars = r.get_vars
    items = get_vars.get('field')
    if items:
        if (not isinstance(items, (list, tuple))):
            items = [items]
        fields = []
        add_fields = fields.extend
        for item in items:
            f = item.split(',')
            if f:
                add_fields(f)
    else:
        fields = None
    if ('hierarchy' in get_vars):
        hierarchy = (get_vars['hierarchy'].lower() not in ('false', '0'))
    else:
        hierarchy = False
    if ('only_last' in get_vars):
        only_last = (get_vars['only_last'].lower() not in ('false', '0'))
    else:
        only_last = False
    if ('show_uids' in get_vars):
        show_uids = (get_vars['show_uids'].lower() not in ('false', '0'))
    else:
        show_uids = False
    representation = r.representation
    flat = False
    if (representation == 'xml'):
        only_last = False
        as_json = False
        content_type = 'text/xml'
    elif (representation == 's3json'):
        show_uids = False
        as_json = True
        content_type = 'application/json'
    elif ((representation == 'json') and fields and (len(fields) == 1)):
        flat = True
        show_uids = False
        as_json = True
        content_type = 'application/json'
    else:
        r.error(415, current.ERROR.BAD_FORMAT)
    component = r.component_name
    output = r.resource.export_options(component=component, fields=fields, show_uids=show_uids, only_last=only_last, hierarchy=hierarchy, as_json=as_json)
    if flat:
        s3json = json.loads(output)
        output = {}
        options = s3json.get('option')
        if options:
            for item in options:
                output[item.get('@value')] = item.get('$', '')
        output = json.dumps(output)
    current.response.headers['Content-Type'] = content_type
    return output
