def __setattr__(self, key, value): if key not in self._fields: if isinstance(value, basestring): self._fields[key] = StringField() elif isinstance(value, int): self._fields[key] = IntegerField() else: self._fields[key] = StringField(_multi=True) super(Doc, self).__setattr__(key, value)
class Address(Document): _doctype = "doc_type" _index = "index" _es = MockES() _validators = [if_city_state_is_required] street = StringField(validators=[max_len_10]) number = IntegerField(required=True) city = StringField() state = StringField()
class DW(D): _es = ES() id = IntegerField() # ID hould be inherited document_id = StringField() house_number = IntegerField() height = FloatField()
class D(Document): _index = _INDEX _doctype = _DOC_TYPE id = IntegerField()
class TowFields(EmbeddedDocument): x = IntegerField() y = IntegerField()