Favoriting system on Appengine

Posted by Mateusz Cieslak on Stack Overflow See other posts from Stack Overflow or by Mateusz Cieslak
Published on 2010-06-07T17:17:07Z Indexed on 2010/06/07 17:22 UTC
Read the original article Hit count: 267

Filed under:

Hi,

I have the following model structure

class Authors(db.Model) :
nickname = db.StringProperty(required=True)
fullname = db.StringProperty(required=True)

class Articles(db.Model) :
title = db.StringProperty(required=True)
body = db.StringProperty(required=True)
author = db.ReferenceProperty(Authors, required=True)

class Favorites(db.Model) :
who = db.ReferenceProperty(Authors, required=True)
what = db.ReferenceProperty(Articles, required=True)


I'd like to display 10 last articles according to this pattern:

article.title, article.body, article.author(nickname), info if this article has been already favorited by the signed in user.

I have added a function which I use to get the authors of these articles using only one query (it is described here)

But I don't know what to do with the favorites (I'd like to know which of the displayed articles have been favorited by me using less than 10 queries (I want to display 10 articles)). Is it possible?

© Stack Overflow or respective owner

Related posts about google-app-engine