I'm implementing a frontpage with "hot" stories based on a certain ranking algorithm. However, I can't figure out how to pass Appengine's datastore my own sort function (like I can in python with sort(key=ranking_function)). I want something like this:
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)
So that I can later call:
Story.all().order("ranking").limit(50)
Any idea how to do this using Appengine's datastore models?