almost:

def give_create_permission(form,table):
        group_id = auth.id_group('user_%s' % auth.user.id)
        auth.add_permission(group_id, 'read', table)

and

auth.settings.register_onaccept = (lambda form,
table=table:give_create_permission(form,table))



On Aug 28, 3:22 pm, Johann Spies <[email protected]> wrote:
> A question about the example in the book (Authorization and CRUD:
>
> def give_create_permission(form):
>     group_id = auth.id_group('user_%s' % auth.user.id)
>     auth.add_permission(group_id, 'read', db.comment)
>
> etc...
>
> auth.settings.register_onaccept = give_create_permission
> crud.settings.auth = auth
>
> I have many forms and tables for which I want to do this.  Is it
> possible to specify something like
>
> def give_create_permission(form,table):
>         group_id = auth.id_group('user_%s' % auth.user.id)
>         auth.add_permission(group_id, 'read', table)
>
> and
> auth.settings.register_onaccept = give_create_permission(table)
>
> ?
>
> If not, in the light of "doing something only once"  how can I do this
> without having to write all the stuff in the example for each
> form/table?
>
> Regards
> Johann
> --
>     "Be not deceived; God is not mocked: for whatsoever a
>      man soweth, that shall he also reap."
>                                   Galatians 6:7

Reply via email to