示例#1
0
class Product(pdmodels.DefinedDict):

    name = pdmodels.StringField(is_required=True)
    price = pdmodels.FloatField(is_required=True)
    stock = pdmodels.IntField(default_value=0)

    product_info = pdmodels.VariableDefinedDictField("type", {
        "book": Book,
        "pen": Pen,
    })
示例#2
0
 class Book(pdmodels.DefinedDict):
     id = pdmodels.StringField(regex="\d{4}-\d{4}-[A-Z]")
示例#3
0
 class Book(pdmodels.DefinedDict):
     name = pdmodels.StringField()
示例#4
0
 class Book(pdmodels.DefinedDict):
     status = pdmodels.StringField(default="available")
示例#5
0
 class Book(pdmodels.DefinedDict):
     category = pdmodels.StringField(choices={"fiction", "non-fiction"})
示例#6
0
class Pen(pdmodels.DefinedDict):

    color = pdmodels.StringField(is_required=True,
                                 choices={"red", "blue", "green"})
    type = pdmodels.StringField(fixed_value="pen")
示例#7
0
class Book(pdmodels.DefinedDict):

    id = pdmodels.StringField(is_required=True, regex="\d{4}-[A-Z]+")
    author = pdmodels.StringField()
    type = pdmodels.StringField(fixed_value="book")
示例#8
0
 class Book(pdmodels.DefinedDict):
     name = pdmodels.StringField(is_required=True)