This is what I settled with:

if auth.is_logged_in() \
        and auth.has_membership('Operations', auth.user.id) \
        and not auth.has_membership('Admin', auth.user.id):

    opdb = DAL(dal_connection, folder=folder, pool_size=pool_size,
check_reserved=check_reserved)

    for table in db.tables:
        if table in ('table1', 'table2', 'table3', 'table4', 'table5',
'table6'):
            tbs = [copy.copy(f) for f in db[table]] # very funny

            opdb.define_table(table,
                *tbs, migrate=False,
                fake_migrate=False)

    db = opdb

So obviously if they are admin, it leaves it alone and they see all tables.

Also all tables are decorated with @auth.reuquires_membership('Operations')

--
Thadeus





On Thu, May 27, 2010 at 11:23 AM, Thadeus Burgess <[email protected]> wrote:
> I would like to hide all tables except the selected one from a user
> unless they have specific privileges.
>
> I am thinking maybe the following at the top of appadmin.py
>
> if auth.has_permission('Operations', auth.user.id):
>   tables = [copy.copy(t) for t in db]
>   db = DAL(db._connection)
>   for t in tables: db.define_table(t)
>
> Would this approach work and be appropriate?
>
> --
> Thadeus
>

Reply via email to