You can use auth.user.request_tenant as the default, but you must be
careful because auth is not present before the user logs in. Therefore you
will get key errors if a user not logged in attempts to access a function.
So, insert something like the following in your model before auth creates
the tables:
request_tenant_default = ''
if 'auth' in session:
request_tenant_default = session.auth.user.tenant_link
Then this:
db.common_fields = Field('tenant_link', default=request_tenant_default, ...)
Also every user-accessible function must have at least
@auth.requires_login()
On Friday, June 29, 2012 10:53:42 AM UTC-4, Michele Comitini wrote:
>
> Ovidio,
>
> I wonder if you could use auth.user.id or auth.membership.id as key
> instead of host/ip?
>
> If the above is not viable, Massimo suggestion to have separate
> databases is very good IMHO and you can build a Data Warehouse
> http://en.wikipedia.org/wiki/Data_warehouse by using postgresql
> clustering capabilities or one of many postgresql synchronization
> tools.
>
> mic
>
>
> 2012/6/29 Ovidio Marinho <[email protected]>:
> > Well now after my DAL I have Instructions
> > db = DAL ('postgres :/ / postgres: passwd @ localhost: 5432/mybd')
> >
> db._common_fields=Field('request_tenant',default=request.env.http_host,writable=False,readable=False)]
>
>
> >
> > What happened? in all my tables I have request_tenant the field, and
> > when I do a drive automatically writes the localhost: 8000. But now
> > how is that several users with different hosts with dhcp changing its
> > access each time with a different ip that can work?
> >
> > this post from Massimo does exactly what I want with the school he has
> > provided for various and simultaneous access, I could spend the
> > Massimo setting this app?
> >
> > http://www.mail-archive.com/[email protected]/msg64351.html
> >
> > Ovidio Marinho Falcao Neto
> > Web Developer
> > [email protected]
> > [email protected]
> > ITJP - itjp.net.br
> > 83 8826 9088 - Oi
> > 83 9334 0266 - Claro
> > Brasil
> >
> >
> >
> > 2012/6/28 Massimo Di Pierro <[email protected]>:
> >> Do me the issue is, should all data always be filtered by hospital.
> >> If there should only be filtered in some cases and not in other, use
> >> explicit queries
> >> If some tables are always filtered and some are not, you may want to
> use the
> >> tenant feature.
> >>
> >>
> >> On Thursday, 28 June 2012 05:45:13 UTC-5, Ovidio Marinho wrote:
> >>>
> >>> I can not split into separate database, as the management reports need
> >>> to filter all information. What I need is that the data are shown to
> >>> hosptal (1) is only seen by him. No problem if all hospitals being in
> >>> the same database, so is the question of security in view. When the
> >>> login Hospital (1) is made only data related to hospital (1) should
> >>> appear on the screen.
> >>>
> >>>
> >>>
> >>>
> >>> Ovidio Marinho Falcao Neto
> >>> Web Developer
> >>> [email protected]
> >>> [email protected]
> >>> ITJP - itjp.net.br
> >>> 83 8826 9088 - Oi
> >>> 83 9334 0266 - Claro
> >>> Brasil
> >>>
> >>>
> >>>
> >>> 2012/6/27 Massimo Di Pierro <[email protected]>:
> >>> > I would suggest you use a different database (a different connection
> >>> > string)
> >>> > for each hospital depending on the hostname.
> >>> >
> >>> > <hospital>.domain.com
> >>> > import re; regex = re.compile('.*\://(.*?)/.*
> >>> > db = DAL('postgresq://..../%s' %
> >>> > regex.match(request.env.http_host).group(1))
> >>> >
> >>> > In this way you keep your data separate (which is better for
> security)
> >>> > and
> >>> > will allow you scale horizontally by setting up multiple db server
> >>> > instances.
> >>> >
> >>> >
> >>> >
> >>> > On Wednesday, 27 June 2012 18:07:44 UTC-5, Ovidio Marinho wrote:
> >>> >>
> >>> >> I am making an application to control government medical
> appointments
> >>> >> in more than fifty hospitals all use a single postgres database,
> but
> >>> >> each hospital must have administrator access, Operator and User,
> and
> >>> >> each access must be made with the view of their unique data .
> >>> >>
> >>> >> is this.
> >>> >>
> >>> >>
> >>> >
>