'Convert a filter value according to the field type
before representation
@param rfield: the S3ResourceField
@param value: the value'

@classmethod
def _convert(cls, rfield, value):

    if (value is None):
        return value
    ftype = rfield.ftype
    if (ftype[:5] == 'list:'):
        if (ftype[5:8] in ('int', 'ref')):
            ftype = long
        else:
            ftype = unicode
    elif ((ftype == 'id') or (ftype[:9] == 'reference')):
        ftype = long
    elif (ftype == 'integer'):
        ftype = int
    elif (ftype == 'date'):
        ftype = datetime.date
    elif (ftype == 'time'):
        ftype = datetime.time
    elif (ftype == 'datetime'):
        ftype = datetime.datetime
    elif (ftype == 'double'):
        ftype = float
    elif (ftype == 'boolean'):
        ftype = bool
    else:
        ftype = unicode
    convert = S3TypeConverter.convert
    if (type(value) is list):
        output = []
        append = output.append
        for v in value:
            try:
                append(convert(ftype, v))
            except (TypeError, ValueError):
                continue
    else:
        try:
            output = convert(ftype, value)
        except (TypeError, ValueError):
            output = None
    return output
