'Render this widget as HTML helper object(s)
@param resource: the resource
@param values: the search values from the URL query'

def widget(self, resource, values):

    selected = []
    append = selected.append
    if (not isinstance(values, (list, tuple, set))):
        values = [values]
    for v in values:
        if (isinstance(v, (int, long)) or str(v).isdigit()):
            append(v)
    rfield = S3ResourceField(resource, self.field)
    opts = self.opts
    bulk_select = current.deployment_settings.get_ui_hierarchy_filter_bulk_select_option()
    if (bulk_select is None):
        bulk_select = opts.get('bulk_select', False)
    w = S3HierarchyWidget(lookup=opts.get('lookup'), represent=opts.get('represent'), multiple=opts.get('multiple', True), leafonly=opts.get('leafonly', True), cascade=opts.get('cascade', False), bulk_select=bulk_select, filter=opts.get('filter'), none=opts.get('none'))
    widget = w(rfield.field, selected, **self._attr(resource))
    widget.add_class(self._class)
    return widget
