On Jul 28, 1:43 pm, Carl <[email protected]> wrote:
> I have created MyAuth(Auth)

You mean EnvoyAuth(Auth) ?

> I have override the method register() with
> if self.environment.response.mode == 'buyer':
>     onaccept = registerBuyer
> return super(EnvoyAuth, self).register(next, onvalidation, onaccept,
> log)
> when users have been successfully register, my own registerBuyer is
> called.
> def registerBuyer(form):
> from registerBuyer I can access form.vars.id
> I want to call:
>     group_id = auth.add_group( 'buyer', 'main group')
>     auth.add_membership(group_id, form.vars.id)
> Two questions:
> 1. is this the right approach to implement several different
> registration forms (one for each type of user). User will be able to
> register for multiple services but I don't want them all to have to
> fill in all the user fields (I need more info from buyers than from
> general users for example).

If just needing to change the onaccept then you can do this in the
Controller - no need to extend register():
if mode == 'buyer':
    auth.settings.register_onaccept = lambda form: registerBuyer(form)

> 2. if my approach is fine then how do I access the auth instance that
> was set-up in db.py with auth=EnvoyAuth(globals(),db)

All controllers can see this as just 'auth'
Views would need to have auth passed through to them: return dict
(auth=auth)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to