Have you seen GqlQuery.bind() ?

http://code.google.com/appengine/docs/datastore/gqlqueryclass.html#GqlQuery_bind

-Mahmoud

On Nov 23, 4:47 pm, GAERiddler <[EMAIL PROTECTED]> wrote:
> Hello,
>
> So I am not a Python programmer, though I am currently trying to pick
> it up.
>
> My question is whether there is a way I can stash all my named
> arguments in a dictionary and then pass that off to the GQL query
> somehow?
>
> What I am trying to do is dynamically generate my GQL queries based on
> how my user fills-out a form.
>
> so here's the constructor I am calling:  class GqlQuery(query_string,
> *args, **kwds)
>
> Instead of passing a bunch of arguments in here, is there a way to
> pass or finesse a dictionary object into those arguments?
>
> Being new to Python I was hoping to find a bind() method that accepted
> a dictionary as a parameter and took care of this for me.
>
> Here's some contrived sample code to illustrate my question:
>
> filters = {}
> whereSection = "WHERE "
>
> if (name != None):
>     if (len(filters) > 0):
>             whereSection += "AND "
>     whereSection += "name = :name "
>     filters['name'] = name
>
> if (busRoute != None):
>     if (len(filters) > 0):
>             whereSection += "AND "
>     whereSection += "routeNumber = :routeNumber "
>     filters['routeNumber'] = busRoute.number
>
> if (len(filters) > 0):
>     busesDriven = BusTraffic.gql(whereSection + "ORDER BY yearBuilt",
> filters)
>
> Since that does not work as written, is there a way to get filters
> into a format the **kwds varargs param in the prototype above
> expects?  Seems like there ought to be, if only I had enough of a
> handle on Python.  If not, would it be a useful constructor for the
> AppEngine folks to implement?:
>
> class GqlQuery(query_string, args_dictionary)
>
> My interim solution is to just have a GQL statement for each number of
> bind arguments, which is hacky, but will work for now.
>
> Thanks!
--~--~---------~--~----~------------~-------~--~----~
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