python google app engine programming
On App Engine, I think the best way to do this is to store the total pages inside the Shelf.  Add an IntegerProperty field to the shelf, I'll call it totalPages.  Every time you add or remove a book to the shelf, update totalPages appropriately.  Note that this will need to be done in a transaction.  
Then it's easy to search the Shelf objects by totalPages.
I have 2 models > Shelf and Book in my models.py. The model Book has a field ReferenceProperty(Shelf), it also has a IntegerProperty field that stores the no. of pages in the book. What i am trying to achieve is to get a list of Top 25 Shelf Names according to highest number of Pages (which should be the sum of pages of all the books in that shelf) in descending order.
i am a beginner with python programming. Please advise me.