google app engine - EndPointsModel query by ancestor -


how can query ancestor according user_id token ?

this code:

class myuserclass(endpointmodel):   user_object = ndb.userproperty(required=true, indexed=false)  class mymodel(endpointmodel):   ...      @mymodel.method(user_required=true, name="model.add", path="model")     def add_mymodel(self, my_model):       gplus_user_id = auth_util.get_google_plus_user_id()       if gplus_user_id none:         raise endpoints.forbiddenexception(nidappuser.no_gplus_id)        user = myuserclass.get_or_insert(gplus_user_id, user_object=endpoints.get_current_user())       my_model.parent = user.key.string_id()       my_model.put()       return my_model       @mymodel.query_method(user_required=true, name="list.mymodel", path="models",                           query_fields=('order','attr1',))     def list_models(self, query):       gplus_user_id = auth_util.get_google_plus_user_id()       if gplus_user_id none:         raise endpoints.forbiddenexception(nidappuser.no_gplus_id)        ## here or in thsi decorator function want       ## query.ancestor.(ndb.key(myclassuser, gplus_user_id)) (such db datastore)       ## return query of mymodels belong current user       return query 

and need create query ancestor key of myuserclass key. don't want use solution add field owner in model because query ancestor more fast filters, , me organize db.

thank

you can construct query based on ancestor this:

myancestorkey = ndb.key(myuserclass, gplus_user_id) myquery = mymodel.query(ancestor=myancestorkey) 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -