[google-appengine] How does get_by_key_name work?

2011-01-16 Thread Zeynel
Hello,

I am reading this sample app called overheard
http://code.google.com/appengine/articles/overheard.html to add
ranking functionality to my app.


His models.set_vote() function has a line

vote = Vote.get_by_key_name(key_names = user.email(), parent = quote)

and his Vote model is

class Vote(db.Model):
"""Storage for a single vote by a single user on a single quote.

Index
  key_name: The email address of the user that voted.
  parent:   The quote this is a vote for.

Properties
  vote: The value of 1 for like, -1 for dislike.
"""
vote = db.IntegerProperty(default=0)

Where does he get the key_names? They are not included in the Vote?

models.py is here: 
http://code.google.com/p/google-app-engine-samples/source/browse/trunk/overheard/models.py

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



Re: [google-appengine] How does get_by_key_name work?

2011-01-16 Thread djidjadji
http://code.google.com/appengine/docs/python/datastore/modelclass.html#Model_get_by_key_name

2011/1/16 Zeynel :
> Hello,
>
> I am reading this sample app called overheard
> http://code.google.com/appengine/articles/overheard.html to add
> ranking functionality to my app.
>
>
> His models.set_vote() function has a line
>
> vote = Vote.get_by_key_name(key_names = user.email(), parent = quote)
>
> and his Vote model is
>
> class Vote(db.Model):
>    """Storage for a single vote by a single user on a single quote.
>
>    Index
>      key_name: The email address of the user that voted.
>      parent:   The quote this is a vote for.
>
>    Properties
>      vote: The value of 1 for like, -1 for dislike.
>    """
>    vote = db.IntegerProperty(default=0)
>
> Where does he get the key_names? They are not included in the Vote?
>
> models.py is here: 
> http://code.google.com/p/google-app-engine-samples/source/browse/trunk/overheard/models.py
>
> --
> 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.
>
>

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