The example below would go in a model. It must be executed before every action that accesses the db.comment table. In your code the onaccept is set in an action therefore only valid within the scope of the http request.
On Sep 7, 3:08 pm, Johann Spies <[email protected]> wrote: > Maybe I should rephrase my lack of understanding. > > Can you explain the example from the book: > ================= > def give_create_permission(form): > group_id = auth.id_group('user_%s' % auth.user.id) > auth.add_permission(group_id, 'read', db.comment) > auth.add_permission(group_id, 'create', db.comment) > auth.add_permission(group_id, 'select', db.comment) > > def give_update_permission(form): > comment_id = form.vars.id > group_id = auth.id_group('user_%s' % auth.user.id) > auth.add_permission(group_id, 'update', db.comment, comment_id) > auth.add_permission(group_id, 'delete', db.comment, comment_id) > > auth.settings.register_onaccept = give_create_permission > crud.settings.auth = auth > ------------ > > What is this? Were do you put it and why? In your previous answer > to me you said: > > > You do not want to register the callback with "register_onaccept". you > > want to set these once for all: > > Isn't that what you do in this example? > > --------------------- > def post_comment(): > form = crud.create(db.comment, onaccept=give_update_permission) > comments = db(db.comment.id>0).select() > return dict(form=form, comments=comments) > > def update_comment(): > form = crud.update(db.comment, request.args(0)) > return dict(form=form) > > ---------------------- > > I am afraid your previous answer was way above my understanding. > > Please speek slower :) I seem to be slow to understand this. > > Regards > Johann > > -- > "Be not deceived; God is not mocked: for whatsoever a > man soweth, that shall he also reap." > Galatians 6:7

