'Helper method to generate a filter query selector for the
given field(s) in the given resource.
@param resource: the S3Resource
@param fields: the field selectors (as strings)
@return: the field label and the filter query selector, or None if none of the
field selectors could be resolved'

def _selector(self, resource, fields):

    prefix = self._prefix
    if resource:
        rfield = S3ResourceField(resource, fields)
        label = rfield.label
    else:
        label = None
    if ('levels' in self.opts):
        levels = self.opts.levels
    else:
        levels = current.gis.get_relevant_hierarchy_levels()
    fields = [('%s$%s' % (fields, level)) for level in levels]
    if resource:
        selectors = []
        for field in fields:
            try:
                rfield = S3ResourceField(resource, field)
            except (AttributeError, TypeError):
                continue
            selectors.append(prefix(rfield.selector))
    else:
        selectors = fields
    if selectors:
        return (label, '|'.join(selectors))
    else:
        return (label, None)
