예제 #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)
예제 #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)
예제 #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)
예제 #4
0
class RoleModels(object):
    scientists = related.SetField(Person)