Indeed.  A key should be though of as a UUID/GUID rather then a SQL
key.

On Oct 11, 4:33 pm, "David Symonds" <[EMAIL PROTECTED]> wrote:
> On Sun, Oct 12, 2008 at 6:30 AM, Roy Leban <[EMAIL PROTECTED]> wrote:
>
> > On Aug 22, 9:55 am, "Marzia Niccolai" <[EMAIL PROTECTED]> wrote:
> >>  You can't query for the key, there is really no need.
>
> > I disagree that there is no need. I have some code that deals with a
> > wide variety of models. The name of the model is passed in, so I do
> > not have the model object. I want to do a query like this:
>
> >      q = db.GqlQuery("SELECT * FROM %s WHERE KEY = :k" % tablename,
> > k=key)
> > or    q = db.GqlQuery("SELECT * FROM %s WHERE :f = :v" % tablename,
> > f=field, v=value)   # f happens to be "key"
>
> > but I can't. Yes, I can do this (and it's how I handled it):
>
> >      eval(tablename).get(key)
>
> > but (a) this is considerably clunkier, (b) it throws errors instead of
> > handling an invalid table or key gracefully with no results returned,
> > and (c) it doesn't support the second case, where the field name is a
> > parameter -- you have to special case if (field.lower()=="key")
>
> A key is unique to your application's datastore (in fact it's unique
> across everyone's app), not just a particular model kind. You can just
> do:
>
>   db.get(key)
>
> That will return the entity, or None.
>
> Dave.
--~--~---------~--~----~------------~-------~--~----~
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