Thank you Jonathan. I added the argument host='127.0.0.1:8000' to the URL.
 
I thank user570039 (
http://stackoverflow.com/questions/6087855/django-vs-pylons-vs-web2py-registration-invitation-events
).
 
Here is the final code, corrected from two typos ("uuid" instead of "token") 
:
 
# coding: utf8

def invitation():

    import uuid

    form = FORM </examples/global/vars/FORM>(INPUT</examples/global/vars/INPUT>
(_name='email', requires=IS_NOT_EMPTY </examples/global/vars/IS_NOT_EMPTY>
()),
        INPUT </examples/global/vars/INPUT>(_type='submit'))

    if form.accepts(request </examples/global/vars/request>.vars):
        uuid=str(uuid.uuid4())
        db.invitation.insert(token = uuid)
        mail.send(to=form.vars.email,message='click %s to register' % 
URL</examples/global/vars/URL>
('register',args=uuid,host='127.0.0.1:8000'))
        session </examples/global/vars/session>.latest_invitation=form.vars.
email
        redirect </examples/global/vars/redirect>(URL</examples/global/vars/URL>
('success_invitation'))

    return dict(message=T </examples/global/vars/T>('Invitation to be sent'
),form=form,address=form.vars.email)

def success_invitation():
    return dict()

def register():   # registration after invitation
    if not db(db.invitation.token==request </examples/global/vars/request>.
args(0)).count():   # FIRST TYPO
        redirect </examples/global/vars/redirect>('error')
    delete = lambda 
form:db(db.invitation.token==request</examples/global/vars/request>
.args(0)).delete()  #SECOND TYPO
    return dict(form=auth.register(onaccept=delete))
 
The only problem I now have is to make sure that people who are not invited 
cannot register. How to do that ?
 
Thanks a lot,
Dwayne
 

Reply via email to