Hi Tim,

It's not recommended practice to use the Model._property members of the object.
These variables are implementation dependent.
Better to use the get_value_for_datastore() method of the Property.

2010/6/1 Tim Hoffman <[email protected]>:
> Yep you are doing it wrong.
>
> You have
>
> tagresults = models.Tag.all().order(sort_order).filter("name =
> ",tag_name).fetch(10)
>        article_keys = [f.article.key() for f in tagresults]
>
> The minute you reference f.article you have dereferenced article and
> now have the object, then you
> are fetching its key then fetching the article.
>
> Have a look at 
> http://groups.google.com.au/group/google-appengine-python/browse_thread/thread/9fb2ddf832a16e0e/
> or Nick Johnsons article
> http://www.google.com/url?sa=D&q=http://blog.notdot.net/2010/01/ReferenceProperty-prefetching-in-App-Engine&usg=AFQjCNGu1cRk9JIgOWBwM-6e8FBtTBpkRw
>
> Put simply you should
> article_keys = [f._article for f in tagresults]
>
> Then fetch the articles
>
> results = models.Article.get(article_keys)
>
> In your reverse query you are on the right track except
> you have tags = [t for t in article.tag_set]
>
> You probably want to do a [t for t in article.tag_set.fetch(100)]  or
> similiar
> other wise you will send lots of single fetches.
>
> I haven't addressed caching.
>
> You should run appstats before and after any changes so you can see
> what sort of improvements you are getting.
>
> Rgds

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

Reply via email to