本文整理汇总了Python中Model.Model.get方法的典型用法代码示例。如果您正苦于以下问题:Python Model.get方法的具体用法?Python Model.get怎么用?Python Model.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Category
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import get [as 别名]
'Prince Edward': {}
}
}
}
c = Category()
c.name = 'Root'
c.save()
c.makeTree()
for (category,children) in categories.items():
catFill(category, children, c)
# create product and assign to category
categories = Model.get(Category)
i = 0
while i < 100:
p = Product()
# when these save, Category relationship saving messes up
p.name = ''.join(random.sample('abcdefghijklmnopqrstuvwxyz ', 15))
p.description = ''.join(random.sample('abcdefghijklmnopqrstuvwxyz ', 20))
p.price = str(decimal.Decimal(random.randrange(10000))/100)
category = random.sample(categories, 1)[0]
p.Category = category
p.save()
i += 1
示例2: print
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import get [as 别名]
from Model import Model
from boot import *
print('Print Product ids for each Category')
for category in Model.get(Category):
print(category.name)
for product in category.Product:
print('\t' + product.id, product.name)
Model.done()
示例3: print
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import get [as 别名]
from Model import Model
from boot import *
print('Get first Product, print Category name if any')
products = Model.get(Product)
p = products[0]
print('Product ' + p.id)
cat = p.Category
if cat:
print(p.Category.id)
else:
print('No Category')
Model.done()
示例4: get
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import get [as 别名]
def get(self, itemid):
imglink = Model.get(self,itemid)
if imglink is not None:
img = Image().get(imglink.Imageid)
imglink['uri'] = img.uri if img is not None else ''
return imglink