Re: [flask] Flask multi tenancy
- Dorian Hoxha
- 2015-02-06 @ 20:02
Note, the schema thing doesn't have nothing to do with flask. Find out how
it's done in python and just put it in a before_request function. As far as
I remember, you'll have to do:
something like~ SET SCHEMA xxx;
And you can't set 2 schemas at the same time. So you probably have to
switch in each request.
To make dynamic subdomains:
def add_subdomain_to_global(endpoint, values):
g.subdomain = values.pop('subdomain', None)
def add_subdomain_to_url_params(endpoint, values):
if 'subdomain' not in values:
values['subdomain'] = g.subdomain
The code makes available 'subdomain' in g.subdomain AND adds on each
On Fri, Feb 6, 2015 at 2:18 PM, Daniel Ferreira Jorge <
> Hi, Can someone point me to the right direction? I'm trying to develop a
> multi tenant Flask app using multiple postgres schemas and sqlalchemy.
> Every tenant will access the app using its own subdomain. Also, there is
> another requirement... Each tenant will access its own schema, AND a shared
> I found info on subdomain dispatching and multiple binds, but I need to
> combine this so when a tenant access his subdomains, the application will
> use both the shared schema (common to all tenants) and the tenant private
> schema... Are there any info on this?
> Thank you!
> Daniel Ferreira Jorge