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")
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to