views:

47

answers:

0

In GAE-python, you can model a one-to-many relationship by assigning a reference property to the child model.

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()

This way, I can access the authors property of a book object instance to get a query-able list of all the Author instances that reference it.

What I want to do is supplement the authors property with a method. A trivial example based on the preceding one would be a function that returns just the primary authors sorted in alphabetical. What's the syntax for something like this?