Hi Morten,

On Sat, Jun 20, 2009 at 11:02 AM, Morten Bek Ditlevsen <morten....@gmail.com
> wrote:

> Hi Federico,
>
> Thanks for your answers - I'm just having a bit of a hard time figuring out
> which data store requests happen automatically.


The only cases in which datastore gets or queries are automatically executed
is when first dereferencing a ReferenceProperty. The collection property
that ReferenceProperty creates on the referenced object returns a query,
which you can execute yourself (explicitly with .get() or .fetch(), or
implicitly by iterating over it or calling len() on it).


>
> I wondered because I had an error in the datastore:
>
>   File "/base/data/home/apps/grindrservr/26.334331202299577521/main.py", line 
> 413, in query
>     if result in meStatus.blocks:
>   File "/base/python_lib/versions/1/google/appengine/api/datastore_types.py", 
> line 472, in __cmp__
>
>     for elem in other.__reference.path().element_list():
>
> The 'blocks' property is just like the 'favorites' described in my previous
> mail - and 'result' is a value iterated over the results from a 'keys only'
> query.


The code there is iterating over the elements of each key and comparing
them, rather than iterating over results.

-Nick Johnson


>
>
> So I guess what I don't understand is why the datastore is in play here. I
> know that my results is probably an iterator, but why is this necessary when
> you just query for keys?
> That's what caused be to think that the error might be related to the
> 'blocks' list of keys...
>
> Sincerely,
> /morten
>
>
>
> On Sat, Jun 20, 2009 at 10:22 AM, Federico Builes <
> federico.bui...@gmail.com> wrote:
>
>>
>> Morten Bek Ditlevsen writes:
>>  > Hi there,
>>  > I have an entity with a list property containing keys:
>>  >
>>  >   favorites = db.ListProperty(db.Key, indexed=False)
>>  >
>>  > I suddenly came to wonder:
>>  > If I check if a key is in the list like this:
>>  >
>>  > if thekey in user.favorites:
>>  >
>>  > will that by any chance try and fetch any entities in the
>> user.favorites
>>  > list?
>>  >
>>  > I don't think so, but I would like to make sure! :-)
>>
>> When you do foo in bar it's actually calling Python methods, not the
>> datastore ops., and since
>> Python sees favorites as a list of keys it should not fetch the entities.
>>
>> If you were to do index this and do it in datastore side ("WHERE favorites
>> = thekey") it might have to
>> "un-marshal" the property and do a normal lookup, but I don't think the
>> slowdown is noticeable.
>>
>> --
>> Federico
>>
>>
>>
>
> >
>


-- 
Nick Johnson, App Engine Developer Programs Engineer
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
368047

--~--~---------~--~----~------------~-------~--~----~
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