On Tuesday, March 20, 2012 2:26:20 PM UTC-7, Mike wrote:
>
> I am trying to use the filter() method based on a key argument. For 
> example: 
>
> user_key="agxkZXZ-emFiZXRhLTJyCgsSBFVzZXIYGAw" 
> d=datamodel.Task.all() 
> d.filter("user=",user_key) 
> results=d.fetch(1024) 
> This produces zero results, and its probably because the key isn't in 
> the right format. If this where gql would I have to use the Key() 
> function like this: 
>
> db.gqlQuery("select * from Task where user=Key(:1)",user_key) 
> However I don't think I can use the Key() function within a filter, 
> but there must be some python functional equivalent... Is there a way 
> to properly format a key to be used within the filter() method? 
>
> User is defined as: 
> user = db.ReferenceProperty(None)


You have to wrap user_key in a call to db.Key(), e.g.

d.filter("user =", db.Key(user_key) )

The user_key value you have is a string but the datastore contains a Key 
object, which is a structured thing that will never match any string.

--Guido van Rossum

-- 
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/-/1-foEUHD5q8J.
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