[英]How can you limit the allowed execution time of specific methods in the python version of Google App Engine?
[英](How) can you add methods to a collection of entities in Google App Engine python?
在GAE-python中,您可以通过将参考属性分配给子模型来建立一对多关系的模型。
class Book(db.Model):
title = db.StringProperty()
class Author(db.Model):
book = db.ReferenceProperty(Book, collection_name = 'authors')
is_primary = db.BooleanProperty()
name = db.StringProperty()
这样,我可以访问书籍对象实例的authors
属性,以获取所有引用该对象的Author实例的可查询列表。
我要做的是用一种方法补充authors
属性。 一个基于上述示例的简单示例是一个仅返回按字母顺序排序的主要作者的函数。 这样的语法是什么?
您正在寻找的是一对多房地产。 没有db.Referencelist属性。我想这会帮助您。
class Book(db.Model):
title = db.StringProperty()
class Author(db.Model):
is_primary = db.BooleanProperty()
name = db.StringProperty()
book = Book(title="what is life")
book.put()
author1 = Author(parent=book,is_primary=true,name='author1')
author1.put()
author2 = Author(parent=book,is_primary=true,name='author2')
author2.put()
# from book to authors
book_authors = Author.all().ancestor(book)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.