Ejemplo n.º 1
0
    def decode_value(self, value, typelist=None):
        typelist = [instantiate(t) for t in wrap_list(typelist or [])]
        raw_values = force_unicode(value).split(self.VALUES_SEP)

        decoded_values = []
        for v, type in zip_longest(raw_values, typelist):
            if type is None:
                to_python = force_unicode
            else:
                to_python_factory = self.PROCESSOR_FACTORIES.get(
                    type.__class__)
                if to_python_factory:
                    to_python = to_python_factory(type)
                else:
                    to_python = type.to_python_single
            if v is None:
                continue

            if v == self.NULL_VAL:
                decoded_values.append(None)
            else:
                try:
                    decoded_values.append(to_python(v))
                except ValueError:
                    break

        return decoded_values
Ejemplo n.º 2
0
    def decode_value(self, value, typelist=None):
        typelist = [instantiate(t) for t in wrap_list(typelist or [])]
        raw_values = force_unicode(value).split(self.VALUES_SEP)

        decoded_values = []
        for v, type in zip_longest(raw_values, typelist):
            if type is None:
                to_python = force_unicode
            else:
                to_python_factory = self.PROCESSOR_FACTORIES.get(type.__class__)
                if to_python_factory:
                    to_python = to_python_factory(type)
                else:
                    to_python = type.to_python_single
            if v is None:
                continue

            if v == self.NULL_VAL:
                decoded_values.append(None)
            else:
                try:
                    decoded_values.append(to_python(v))
                except ValueError:
                    break

        return decoded_values
Ejemplo n.º 3
0
 def __init__(self, name, field, alias=None, type=None, compute_enabled=True, compute_min_max=True):
     super(RangeFilter, self).__init__(name, field, alias=alias)
     self.type = instantiate(type or self.field.get_type())
     self._compute_enabled = compute_enabled
     self._compute_min_max = compute_min_max
     self.from_value = None
     self.to_value = None
     self.enabled = None
     self.min = None
     self.max = None
Ejemplo n.º 4
0
 def __init__(self, name, field, alias=None, type=None, compute_enabled=True, compute_min_max=True):
     super(RangeFilter, self).__init__(name, field, alias=alias)
     self.type = instantiate(type or self.field.get_type())
     self._compute_enabled = compute_enabled
     self._compute_min_max = compute_min_max
     self.from_value = None
     self.to_value = None
     self.enabled = None
     self.min = None
     self.max = None
Ejemplo n.º 5
0
    def __init__(
            self, name, path, key_expression, value_field, alias=None,
            type=None, compute_enabled=True, compute_min_max=None,
    ):
        super(NestedRangeFilter, self).__init__(name, alias=alias)

        self.type = instantiate(type or value_field.get_type())
        self.key_expression = key_expression
        self.value_field = value_field
        self.path = path

        self._compute_enabled = compute_enabled
        self._compute_min_max = compute_min_max
        self._from_value = None
        self._to_value = None
Ejemplo n.º 6
0
    def decode_value(self, value, es_type=None):
        es_type = instantiate(es_type)

        if es_type is None:
            to_python = force_unicode
        else:
            to_python_factory = self.PROCESSOR_FACTORIES.get(
                es_type.__class__
            )
            if to_python_factory:
                to_python = to_python_factory(es_type)
            else:
                to_python = es_type.to_python_single

        if value is None or value == self.NULL_VAL:
            return None
        else:
            return to_python(value)
Ejemplo n.º 7
0
    def __init__(
            self, name, path, key_expression, value_field, alias=None,
            type=None, compute_enabled=True, compute_min_max=None,
    ):
        super(NestedRangeFilter, self).__init__(name, alias=alias)

        self.type = instantiate(type or value_field.get_type())
        self.key_expression = key_expression
        self.value_field = value_field
        self.path = path

        self._compute_enabled = compute_enabled
        self._compute_min_max = compute_min_max
        self.from_value = None
        self.to_value = None
        self.enabled = None
        self.min = None
        self.max = None
Ejemplo n.º 8
0
    def __init__(
        self, name, path, key_expression, value_field,
        alias=None, type=None, conj_operator=QueryFilter.CONJ_OR,
        instance_mapper=None, get_title=None, **kwargs
    ):
        super(NestedFacetFilter, self).__init__(name, alias=alias)
        self._instance_mapper = instance_mapper
        self._get_title = get_title
        self._agg_kwargs = kwargs
        self._conj_operator = conj_operator

        self.type = instantiate(type or value_field.get_type())
        self.key_expression = key_expression
        self.value_field = value_field
        self.path = path

        self.values = []
        self.selected_values = []
        self.all_values = []
        self.values_map = {}
Ejemplo n.º 9
0
    def __init__(
        self, name, path, key_expression, value_field,
        alias=None, type=None, conj_operator=QueryFilter.CONJ_OR,
        instance_mapper=None, get_title=None, **kwargs
    ):
        super(NestedFacetFilter, self).__init__(name, alias=alias)
        self._instance_mapper = instance_mapper
        self._get_title = get_title
        self._agg_kwargs = kwargs
        self._conj_operator = conj_operator

        self.type = instantiate(type or value_field.get_type())
        self.key_expression = key_expression
        self.value_field = value_field
        self.path = path

        self.values = []
        self.selected_values = []
        self.all_values = []
        self.values_map = {}
Ejemplo n.º 10
0
 def encode_value(self, value, typelist=None):
     typelist = [instantiate(t) for t in wrap_list(typelist or [])]
     return self.VALUES_SEP.join(
         self._encode_value(v, t)
         for v, t in zip_longest(wrap_list(value), typelist))
Ejemplo n.º 11
0
 def __init__(self, name, field, alias=None, type=None):
     super(FieldFilter, self).__init__(name, alias=alias)
     self.field = field
     self.type = instantiate(type or self.field.get_type())
Ejemplo n.º 12
0
 def __init__(self, name, field, alias=None, type=None):
     super(FieldFilter, self).__init__(name, alias=alias)
     self.field = field
     self.type = instantiate(type or self.field.get_type())
Ejemplo n.º 13
0
 def encode_value(self, value, es_type=None):
     es_type = instantiate(es_type)
     return self._encode_value(value, es_type)