Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:35:34+00:00 2026-06-11T21:35:34+00:00

Let’s assume that we the following ndb model: class MyModel(ndb.Model): x = ndb.StringProperty() y

  • 0

Let’s assume that we the following ndb model:

class MyModel(ndb.Model):
    x = ndb.StringProperty()
    y = ndb.StringProperty()
    z = ndb.StringProperty(repeated=True)

We have a method that creates a query for the above model, executes it and fetch the results. However, we want this query to be modified my other functions. Specifically, we have the following:

def method_a():
    qry = MyModel.query() 
    values = {'query':qry}
    method_b(**values)
    entities = qry.fetch()

def method_b(**kwargs):
    k = ['a', 'b', 'c']
    qry = kwargs['query']
    qry.filter(MyModel.z.IN(k))

The problem is that the Query object is immutable, and thus it cannot be modified by method_b. Also, based on the specific architecture of the code, we cannot have method_b to return the new Query to method_a.

Any ideas on how to achieve the aforementioned functionality in another way??

Update: Please check the architecture of my code as presented below:

First, in a configuration file we specify a list of modules and if they are enabled or not. These modules affect the filters of the query we want to execute.

testparams = {
    'Test1': True,
    'Test2': True,
    'Test3': False,
    'Test4': True
}

Then, we have a method somewhere in the code that makes a query after the appropriate modules have been executed. Thus, it seems like this:

def my_func():
    qry = MyEntity.query()

    # modules
    query_wrapper = [qry]
    values = {'param':'x', 'query_wrapper':query_wrapper} #other values also
    execute_modules(**values)
    # get query and add some more things, like ordering
    entities = query_wrapper[0].fetch()

The execute_modules function is the following:

def execute_modules(**kwargs):
    for k in config.testparams:
        if config.testparams[k]:
            if kwargs['param'] == 'x':
                (globals()[k]).x(**kwargs)
            elif kwargs['param'] == 'y':
                (globals()[k]).y(**kwargs)

Finally, an indicative module is similar to the following:

class Test1():
    @classmethod
    def x(cls, *args, **kwargs):
        qry = kwargs['query_wrapper'][0]
        # do some stuff like adding filters
        kwargs['query_wrapper'][0] = qry

Any proposals to modify this architecture to a better approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:35:35+00:00Added an answer on June 11, 2026 at 9:35 pm

    I’m not aware of a way to do this without having method_b either return or change a referenced parameter. You should use a technique to pass a variable by reference, like passing a class with parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me explain best with an example. Say you have node class that can
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have the following classes : public class MyProductCode { private String
Let assume we have two activities. A - main activity, that is home launcher
Let's say you have a method that expects a numerical value as an argument.
Let's say I had a model that looked something like this: class SomeModel def
Let's say I have a JAR xxx-core.jar with the following classes: @XmlRootElement @XmlSeeAlso({Imp1.class, Imp2.class})
Let's suppose I have a Discussion model, and that a discussion can be tagged.
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say you have a class, with certain properties, and that you tried your

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.