7 messages in com.googlegroups.google-appengine[google-appengine] Re: Does getting t...
FromSent OnAttachments
palp29 Apr 2008 00:52 
Ben the Indefatigable29 Apr 2008 19:03 
Ross Ridge30 Apr 2008 00:28 
palp30 Apr 2008 01:09 
Filip30 Apr 2008 01:18 
palp30 Apr 2008 01:46 
Filip30 Apr 2008 03:34 
Subject:[google-appengine] Re: Does getting the key of a ReferenceProperty hit the datastore?
From:palp (palp@gmail.com)
Date:04/30/2008 01:09:43 AM
List:com.googlegroups.google-appengine

Thanks, that worked like a charm.

On Apr 30, 12:28 am, Ross Ridge <rri@csclub.uwaterloo.ca> wrote:

palp wrote:

This is a pretty straighforward question, but I haven't seen much detail on how ReferenceProperty actually works under the hood. I have an entity that has a reference to another entity. I want to use the application cache to minimize lookups of entities. If I do entity.reference.key(), am I saving anything at all, or does it cost the same as accessing the properties of the reference?

I don't think it saves you anything at all. Looking at the source for the ReferenceProperty class in the SDK, I think you'd have to something like this:

key = type(entity).reference.get_value_for_datastore(entity)

By accessing the property through the entity's class rather than the entity, you can get the property itself rather than entity it refers to. You can replace "type(entity)" with the name of the entiy's class.

Ross Ridge