我正在基于某种排名算法实现带有“热门”故事的首页。但是,我无法弄清楚如何通过我自己的排序函数传递App Engine数据存储区(就像我可以在Python中使用sort(key = ranking_function)一样)。我想要这样的东西:
class Story(db.Model):
user = db.ReferenceProperty(User)
text = db.TextProperty()
def ranking(self):
# my ranking function, returns an int or something
return 1
ranking = property(ranking_function)
以便我以后可以打电话:
Story.all().order("ranking").limit(50)
知道如何使用App Engine数据存储区模型进行此操作吗?