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 7677021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:19:48+00:00 2026-05-31T17:19:48+00:00

what im trying to do is to load different applications (webapp2.WSGIApplication) depending on the

  • 0

what im trying to do is to load different applications (webapp2.WSGIApplication) depending on the request domain.
for example http://www.domain_1.com should load the application in app1.main.application while http://www.domain_2.com should load app2.main.appplication.
of course im on the same GAE appid and im using namespaces to separate the apps data.

this works pretty good with ‘threadsafe:false’ and a runner.py file where a function determines which application to return

it seems that with ‘threadsafe:true’ the first request loads the wsgiapplication into the instance and further requests dont execute the ‘application dispatching’ logic any more so the request gets a response from the wrong app.

im using python2.7 and webapp2

what is the best way to do this?

edit:

a very simplified version of my runner.py

def main():
    if domain == 'www.mydomain_1.com':
        from app_1 import application
        namespace = 'app_1'
    elif domain == 'www.domain_2.com':
        from app_2 import application
        namespace = 'app_2'
    namespace_manager.set_namespace(namespace)
    return wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__':
    main()

and in app.yaml

- url: /.*
  script: app-runner.py
  • 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-05-31T17:19:49+00:00Added an answer on May 31, 2026 at 5:19 pm

    made it happen by subclassing webapp2.WSGIApplication and overriding __call__() which is called before dispatching to a RequestHandler.
    prefixing routes (and removing the prefix in the handlers initialize) and substructuring config to be able to use the instance memory.

    class CustomWSGIApplication(webapp2.WSGIApplication):
    
        def __call__(self, environ, start_response):
    
            routes, settings, ns = get_app(environ)
            namespace_manager.set_namespace(ns)
    
            environ['PATH_INFO'] = '/%s%s' %(ns, environ.get('PATH_INFO'))
    
            for route in routes:
                r, h     = route # returns a tuple with mapping and handler
                newroute = ('/%s%s'%(ns, r), h,)
                self.router.add(newroute)
    
    
            if settings:
                self.config[ns] = settings
    
            self.debug  = debug
    
            with self.request_context_class(self, environ) as (request, response):
                try:
                    if request.method not in self.allowed_methods:
                        # 501 Not Implemented.
                        raise exc.HTTPNotImplemented()
    
                    rv = self.router.dispatch(request, response)
                    if rv is not None:
                        response = rv
                except Exception, e:
                    try:
                        # Try to handle it with a custom error handler.
                        rv = self.handle_exception(request, response, e)
                        if rv is not None:
                            response = rv
                    except HTTPException, e:
                        # Use the HTTP exception as response.
                        response = e
                    except Exception, e:
                        # Error wasn't handled so we have nothing else to do.
                        response = self._internal_error(e)
    
                try:
                    return response(environ, start_response)
                except Exception, e:
                    return self._internal_error(e)(environ, start_response)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wanted to load a different timezone for my application depending on a
I am trying to load/show completely different set of values in a combobox(this one
I am trying to load a swf into an Ogre3d/Hikari application and that swf
I'm programming my first iOS application and I'm trying to asynchronously load images into
I am trying to load test a web application that uses SAML for SSO,
I making an application launcher, Launcher.exe. I'm trying to have it load a config
I am trying to figure out how to load different groupviews dynamically. I am
I am trying to make a simple Windows Form application that will show different
I have a problem with out of memory when I'm trying load a few
Trying to load a shared lib out of the current '.' dir in a

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.