def deserialize(self, data: dict): self._source = serializer.simple_deserialize(data['source']) self.__origin = FieldValue.create( serializer.simple_deserialize(data['origin'])) self.__matched = FieldValue.create( serializer.simple_deserialize(data['matched'])) self.__suggested = FieldValue.create( serializer.simple_deserialize(data['suggested'])) if 'exclude' in data: self._exclude = FieldValue.create( serializer.simple_deserialize(data['exclude']))
def match(self, form): LOG.info("Match field %s with value %s" % (self._source, self.__origin)) if self._matcher: if not FieldValue.is_empty(self.__origin): matched_value = self._matcher(self.__origin, form) self._validate_match(matched_value) self.__matched = FieldValue.create(matched_value) LOG.info("Matched value for field %s is %s(%s)" % (self._source, self.__matched.__class__.__name__, self.__matched))
def _to_suggest_fieldvalue(self, value): if FieldValue.is_empty(self.origin): return super(ListField, self)._to_suggest_fieldvalue(value) return FieldValue.create(value)
def _fill_origin(self, raw_payload): self.__origin = FieldValue.create(raw_payload.get(self._source, None))