-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
32 lines (25 loc) · 894 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import models, fields
class Shoe(models.Model):
color = fields.StringField()
size = fields.StringField()
material = fields.StringField()
cordon = fields.ObjectField()
class Cordon(models.Model):
material = fields.StringField()
color = fields.StringField()
if __name__ == '__main__':
shoe = Shoe(color='green', size='23', material='nylon', cordon=Cordon(material='nylon', color='blue'))
shoe.save()
Shoe.objects.find()
myshoe = shoe.deserialize({
'__type__': {'class': 'Shoe', 'module': '__main__'},
'color': 'green',
'size': '23',
'material': 'nylon',
'cordon': {'__type__': {'class': 'Cordon', 'module': '__main__'},
'material': 'nylon', 'color': 'blue'}
})
print(myshoe.get_color)
print(myshoe.get_size)
print(myshoe.get_cordon.get_color)
print(myshoe.get_material)