librelist archives

« back to archive

Loading different configurations based on request.host

Loading different configurations based on request.host

From:
Paul Burt
Date:
2011-01-12 @ 14:14
Hi there,

I'm working on a multi-tenant app at the moment which will be served
from two different URLs. For the sake of argument, let's say
"this.domain.com" and "that.domain.com". I'm implementing it on Google
App Engine.

I'd like to configure my app to load separate site-specific
configurations based on request.host - ie if the user comes in on
this.domain.com, the app configures itself from my_app.config.this and
so forth.

The structure I have is:

my_app/
    config/
        __init__.py
        common.py
        this.py
        that.py

However I can't come up with a way to branch app.config.from_object()
accordingly in my application's __init__ because it's outside of the
request and os.environ is not reliable for these purposes with Google
App Engine.

Has anyone got any experience of a similar situation or any code
they'd be willing to share?

Cheers,
Paul

----
Paul Burt
http://www.pyandmash.com/

Re: [flask] Loading different configurations based on request.host

From:
heww0205
Date:
2011-01-12 @ 18:23
Oh,  multiple-domain (virtual hosting) configuration  is not supported by
flask, but pylons does. See
http://countergram.com/pylons-virtual-host-multiple-domain

2011/1/12 Paul Burt <paul.burt@gmail.com>

> Hi there,
>
> I'm working on a multi-tenant app at the moment which will be served
> from two different URLs. For the sake of argument, let's say
> "this.domain.com" and "that.domain.com". I'm implementing it on Google
> App Engine.
>
> I'd like to configure my app to load separate site-specific
> configurations based on request.host - ie if the user comes in on
> this.domain.com, the app configures itself from my_app.config.this and
> so forth.
>
> The structure I have is:
>
> my_app/
>    config/
>        __init__.py
>        common.py
>        this.py
>        that.py
>
> However I can't come up with a way to branch app.config.from_object()
> accordingly in my application's __init__ because it's outside of the
> request and os.environ is not reliable for these purposes with Google
> App Engine.
>
> Has anyone got any experience of a similar situation or any code
> they'd be willing to share?
>
> Cheers,
> Paul
>
> ----
> Paul Burt
> http://www.pyandmash.com/
>