Thank you. So I will make a 30 dollar donation to the project. But it still does not work.
This is what I get when I enter an email address to invite someone : Traceback (most recent call last): File "gluon/restricted.py", line 181, in restricted File "C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/invitation.py", line 16, in <module> File "gluon/globals.py", line 133, in <lambda> File "C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/invitation.py", line 6, in invitation File "gluon/dal.py", line 4048, in __getattr__ File "gluon/dal.py", line 4042, in __getitem__ KeyError: 'invitation' And this is what I get when I try to register using any address : Traceback (most recent call last): File "gluon/restricted.py", line 181, in restricted File "C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/default.py", line 50, in <module> File "gluon/globals.py", line 133, in <lambda> File "C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/default.py", line 30, in user File "gluon/tools.py", line 1042, in __call__ File "gluon/tools.py", line 1657, in register File "gluon/sqlhtml.py", line 1031, in accepts File "gluon/html.py", line 1732, in accepts File "C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/models/db.py", line 51, in <lambda> File "gluon/dal.py", line 4048, in __getattr__ File "gluon/dal.py", line 4042, in __getitem__ KeyError: 'invitation' What's the problem ? Thank you very much. Dwayne On 21 juin, 05:31, Massimo Di Pierro <[email protected]> wrote: > My mistake, should have been > > form.errors.update({'email':'not allowed'}) > > By adding the error message it prevent the user from registering > (because he does not have a valid token). > > You do not need to pay me for help in this list but I will not refuse > a donation. ;-) > > Massimo > > On Jun 20, 8:16 pm, Dwayne <[email protected]> wrote: > > > > > Dear Massimo, > > > Thank you very much. I'll send you the 30 dollars if it works :) > > > I have a problem. I cannot compile : > > > auth.settings.register_onvalidation.append(lambda form: > > db.invitation(token=form.vars.email) or > > form.errors.update({'email','not allowed'})) > > > Why do I need : form.errors.update({'email','not allowed'}) ? > > > Thank you very much ! > > > Dwayne > > > On 20 juin, 02:09, Massimo Di Pierro <[email protected]> > > wrote: > > > > OK try this: > > > > definvitation(): > > > form = SQLFORM.factory(Field('email',requires=IS_EMAIL())) > > > if form.accepts(request): > > > db.invitation.insert(token = form.vars.email) > > > MESSAGE = 'click %s to register' > > > url = URL('user/register',host=request.env.http_host) > > > mail.send(to=form.vars.email, message=MESSAGE % url) > > > redirect('success_invitation')) > > > return dict(message=('Invitationto be sent'), > > > form=form,address=form.vars.email) > > > > auth.settings.register_onvalidation.append(lambda form: > > > db.invitation(token=form.vars.email) or > > > form.errors.update({'email','not allowed'})) > > > auth.settings.register_onaccept.append(lambda form: > > > db(db.invitation.token==form.vars.email).delete()) > > > > On Jun 4, 9:28 am, Dwayne Blind <[email protected]> wrote: > > > > > Can somebody please help me ? I would really want this to work. > > > > > I customized db.auth_user, as described in the book, to add a 'token' > > > > field. I just added : Field('token', writable=False, readable=False, > > > > default=''). > > > > > Then, in the controllers, I modified default.py : > > > > > def user(): > > > > db.auth_user.insert(token=request.args(1)) > > > > return dict(form=auth()) > > > > > Then in the models, I modified db.py : > > > > > def my_auth_processing(form): > > > > if db(db.auth_user.token!='') > > > > (db.invitation.token==db.auth_user.token): > > > > return True > > > > else : > > > > return False > > > > > auth.settings.register_onvalidation.append(lambda form: > > > > my_auth_processing(form)) > > > > > But unfortunately no one is prevented from registering... So this does > > > > not work. > > > > > Dwayne > > > > > On 2 juin, 02:31, pbreit <[email protected]> wrote: > > > > > > Oops. For registration, you use > > > > > this:http://web2py.com/book/default/chapter/08?search=register_onvalidatio...le > > > > > texte des messages précédents - > > > > - Afficher le texte des messages précédents -- Masquer le texte des > > > messages précédents - > > - Afficher le texte des messages précédents -

