Hi Simon,

A wild guess would be that your are not looking at the same entities
in both methods, try to check the entity key using topic.key()

You might also want to check that article about Modeling your data on
App Engine:
http://code.google.com/appengine/articles/modeling.html

Hope that helps.

On Mon, Aug 1, 2011 at 8:43 AM, Simon <simon.p.saf...@gmail.com> wrote:
> Hi,
>
> I'm new to appengine and I'm trying to write an app in python, however I
> don't think that my problem is python specific.
> If somebody else already asked the same question, I'm sorry for repeating
> it. I searched for quite a while and couldn't find anything.
>
> My app is a message board application where each user entity has a list of
> all the topics (threads) the user has participated in and each topic has a
> list of all users that have participated, like this.
>
> class User(db.Model):
>     user_account = db.UserProperty()
>     topic_keys = db.ListProperty(db.Key)
>
>     @property
>     def topics(self):
>         if len(self.topic_keys) == 0:
>             return []
>         return db.get(self.topic_keys)
>     ...
>
> class Topic(db.Model):
>     name = db.StringProperty(multiline=True, required=True)
>     user_keys = db.ListProperty(db.Key)
>
>     @property
>     def users(self):
>         if len(self.user_keys) == 0:
>             return []
>         return db.get(self.user_keys)
>
> In the get method of a request handler I tried to retrieve the list of users
> that have participated in the topic
>
> topic_list = Topic.all().filter("name =",topic_id).fetch(limit=1)
> if len(topic_list) > 0:
>     topic = topic_list[0]
>     topic_users = topic.users
> ...
>
> But doing this gives me a Topic instance where the 'name' property is
> correct but topic.users is empty. However if I try to fetch the topic like
> below, the topic.users I get isn't empty
>
> for tpc in pmwuser.topics:
>     if tpc.name == topic_id:
>         topic = tpc
>         topic_users = tpc.users
>
> What am I doing wrong in the first case? Am I modelling this wrong all
> together? Any help would be appreciated.
>
> Thanks in advance
>
> Simon
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/BxbGdTqS6pcJ.
> To post to this group, send email to google-appengine@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>



-- 
Johan Euphrosine (proppy)
Developer Programs Engineer
Google Developer Relations

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to