Hi

I am using the web2py default auth table for user registration.

I am having an additional table defined as such:

db.define_table('nsksystem',
                Field('email_id', db.auth_user,length=512, label = 'Email 
ID'),
                Field('nskname', length=128, default='', label = 'Machine 
Name'),
                Field('nskpassword', 'password', length=512,readable=False, 
label='Machine Password'),
                Field('confirmnskpassword', 'password', 
length=512,readable=False, label='Confirm Machine Password'),
                Field('nreleaseid',length=128, default='',label = 
'Release'),
                Field('isCordinator','boolean',default='', label = 'Is 
Co-ordinator'))


db.nsksystem.email_id.requires = 
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
db.nsksystem.email_id.requires = IS_IN_DB(db,'auth_user.email','%(email)s')
db.nsksystem.nreleaseid.requires = 
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
db.nsksystem.nskname.requires = 
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
db.nsksystem.confirmnskpassword.requires = IS_EXPR('value==%s' % 
repr(request.vars.get('nskpassword', None)),error_message='Passwords do not 
match')
db.nsksystem.isCordinator.requires=IS_NOT_IN_DB(db(db.nsksystem.nreleaseid 
== request.vars.nreleaseid), 'nsksystem.isCordinator', 
error_message='Co-ordinator Already exist for specified release')

In my Controller:

def uregistration(): ##---> For my user registration
    form=SQLFORM(db.auth_user)
    if form.process().accepted:
        response.flash = 'User is registered. Redirecting to machine 
registration'
        redirect(URL('mregistration'))     #-> After registration it goes 
to another page for machine registration.
    elif form.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill out the form'
    return dict(form=form)


def mregistration():  ##---> for machine registration page
    form=SQLFORM(db.nsksystem) 
    if form.process().accepted:
        response.flash = 'Machine is registered to user. Please go to Login 
page.'
        redirect(URL('index'))
    elif form.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill out the form'
    return dict(form=form)

Now after I have registered the user, i am being redirected to Machine 
registration page. After i enter all the details in Machine registration 
page I get this error:

Traceback (most recent call last):
  File "gluon/restricted.py", line 224, in restricted
  File "C:/web2py/applications/click/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/click/controllers/default.py>, line 
63, in <module>
  File "gluon/globals.py", line 393, in <lambda>
  File "C:/web2py/applications/click/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/click/controllers/default.py>, line 
30, in mregistration
    if form.process().accepted:
  File "gluon/html.py", line 2303, in process
  File "gluon/html.py", line 2240, in validate
  File "gluon/sqlhtml.py", line 1677, in accepts
  File "gluon/dal/objects.py", line 724, in insert
  File "gluon/dal/adapters/base.py", line 715, in insert
IntegrityError: foreign key constraint failed

Error snapshot  <class 'sqlite3.IntegrityError'>(foreign key constraint failed) 
 
      Function argument list
      
(self=<gluon.dal.adapters.sqlite.SQLiteAdapter object>, 
table=<Table nsksystem 
(id,email_id,nskname,nskpassword,confirmnskpassword,nreleaseid,isCordinator)>,
 fields=[(<gluon.dal.objects.Field object>, '123456'), 
(<gluon.dal.objects.Field object>, 'vodka.ind.codefactory.com'), 
(<gluon.dal.objects.Field object>, 0), 
(<gluon.dal.objects.Field object>, True), 
(<gluon.dal.objects.Field object>, 'AAA'), 
(<gluon.dal.objects.Field object>, '123456')])


I wonder why i dont see the email address that i select in the machine 
registration page. (<gluon.dal.objects.Field object>, 0) in the Function 
argument list refers to email id or only ID.

I am confused. Unfortunately i cant turn the constraint validation off as it is 
a requirement.
    

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to