The problem is: import uuid
def invitation(): .... uuid ... uuid = ... the interpreter thinks the uuid in the function is a local one and not the same uuid defined outside by the import. On May 30, 7:43 pm, Dwayne Blind <dwaynebl...@gmail.com> wrote: > 1. # coding: utf8 > 2. import uuid > 3. > 4. def invitation(): > 5. > 6. form = FORM(INPUT(_name='email', requires=IS_NOT_EMPTY()), > 7. INPUT(_type='submit')) > 8. > 9. if form.accepts(request.vars): > 10. uuid=str(uuid.uuid4()) > 11. db.invitation.insert(token = uuid) > 12. mail.send(to=form.vars.email,message='click %s to > register' % URL('register',args=uuid)) > 13. redirect(URL('index')) > 14. > 15. return dict(form=form) > 16. > > 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 17, in <module> > File "gluon/globals.py", line 133, in <lambda> > File "C:/Users/Coco/Downloads/web2py_win/web2py/applications/ > myproject/controllers/invitation.py", line 10, in invitation > UnboundLocalError: local variable 'uuid' referenced before assignment > > (The traceback is the same.) > > On 31 mai, 02:03, pbreit <pbreitenb...@gmail.com> wrote: > > > > > > > > > We need to see the code and the error message.