Ejemplo n.º 1
0
class Model(object):
    # non-child fields
    sequence_field = related.SequenceField(str, default=set())
    set_field = related.SetField(str, default=[])
    mapping_field = related.MappingField(Child, "name", default={})

    # child fields
    child_list = related.ChildField(list, default=list)
    child_set = related.ChildField(set, default=set)
    child_dict = related.ChildField(dict, default=dict)
    child_obj = related.ChildField(Child, default=Child)
Ejemplo n.º 2
0
class Company(object):
    name = related.StringField()
    uuid = related.UUIDField()
    email = related.RegexField("[^@]+@[^@]+", required=False)
    is_active = related.BooleanField(required=False)
    url = related.URLField(required=False)
    meta = related.ChildField(dict, required=False)
    nicknames = related.SequenceField(str, required=False)
    temperature = related.FloatField(required=False)
    guess = related.SetField(int, required=False)
    established = related.DateField('%m/%d/%Y', required=False)
    closed = related.DateField(required=False)  # default formatter (%Y-%m-%d)
Ejemplo n.º 3
0
class EmailMessage(object):
    '''Mailgun message
    '''

    subject = related.StringField()
    body = related.StringField()
    html = related.StringField()
    to_addr = related.StringField()
    cc = related.SetField(str, required=False)
    bcc = related.SetField(str, required=False)
    attachments = related.SetField(tuple, required=False)

    tag = related.StringField(required=False)
    sender = related.StringField(required=False)

    def add_cc(self, mail_addr):
        self.cc.add(mail_addr)

    def add_bcc(self, mail_addr):
        self.bcc.add(mail_addr)

    def to_json(self):
        return related.to_json(self)
Ejemplo n.º 4
0
class RoleModels(object):
    scientists = related.SetField(Person)