def sanitize_query(query, db_func, on_behalf_of=None):
 q = copy.copy(query)
 auth_project = get_auth_project(on_behalf_of)
 if auth_project:
  _verify_query_segregation(q, auth_project)
  proj_q = [i for i in q if (i.field == 'project_id')]
  valid_keys = inspect.getargspec(db_func)[0]
  if ((not proj_q) and ('on_behalf_of' not in valid_keys)):
   q.append(base.Query(field='project_id', op='eq', value=auth_project))
 return q

def sanitize_query ( query , db_func , on_behalf_of = None ) : q = copy . copy ( query ) auth_project = get_auth_project ( on_behalf_of ) if auth_project : _verify_query_segregation ( q , auth_project ) proj_q = [ i for i in q if ( i . field == 'project_id' ) ] valid_keys = inspect . getargspec ( db_func ) [ 0 ] if ( ( not proj_q ) and ( 'on_behalf_of' not in valid_keys ) ) : q . append ( base . Query ( field = 'project_id' , op = 'eq' , value = auth_project ) ) return q
check the query .