As far as variable references, are dk2, dk, and db all the same database? There is something funny about:
db(dk, 'jusers').insert(...) should it be: dk2.jusers.insert(...) Robin On Jan 2, 12:44 pm, LB22 <latn.bl...@googlemail.com> wrote: > Hi there, > > I'm fairly new to both python and web2py, and I've run into a problem > that I just can't seem to get around. I'm hoping someone can help. If > anymore info is need, please let me know. > > So, I keep getting this error: > > Traceback (most recent call last): > File "gluon\restricted.pyc", line 62, in restricted > File "C:\Documents and Settings\Latn\Desktop\web2py_win\web2py > \applications\dkt/controllers/uregister.py", line 29, in <module> > File "gluon\globals.pyc", line 55, in <lambda> > File "C:\Documents and Settings\Latn\Desktop\web2py_win\web2py > \applications\dkt/controllers/uregister.py", line 16, in uregister > File "gluon\sqlhtml.pyc", line 172, in accepts > File "gluon\html.pyc", line 490, in accepts > File "gluon\html.pyc", line 136, in _traverse > File "gluon\html.pyc", line 136, in _traverse > File "gluon\html.pyc", line 136, in _traverse > File "gluon\html.pyc", line 136, in _traverse > File "gluon\html.pyc", line 139, in _traverse > File "gluon\html.pyc", line 366, in _validate > File "gluon\validators.pyc", line 183, in __call__ > File "gluon\sql.pyc", line 300, in __getitem__ > KeyError: 'jusers' > > I don't understand why though. This is the Model for the jusers table: > > dk2.define_table('jusers', > SQLField('displayname',length=32,requires= > [IS_NOT_EMPTY(),IS_LENGTH(32),]), > SQLField('username',length=40,requires= > [IS_NOT_EMPTY(),IS_EMAIL(), IS_NOT_IN_DB(dk2,'jusers.username')]), > SQLField('password',requires=IS_NOT_EMPTY()), > SQLField('regdate','datetime',default=now), > SQLField('retiredate','datetime',default=now), > SQLField('active','boolean',default=True)) > > And the Controller for my registration form: > > def uregister(): > form = form_factory(SQLField('displayname',requires=IS_NOT_EMPTY > (),label='Display Name'),\ > SQLField('username',requires=[IS_NOT_EMPTY(),IS_EMAIL > (error_message=T('Hey, this has to be an email address!')),IS_NOT_IN_DB > (dk,'jusers.username')],label='Email Address'),\ > SQLField('password','password',label='Password')) > > if form.accepts(request.vars,session): > db(dk, 'jusers').insert(displayname='form.vars.displayname', > username='form.vars.username', password='form.vars.password', > regdate='now') > response.flash="Registration Accepted" > > elif form.errors: > response.flash="Sorry, there was a problem with your > Registration" > > else: > response.flash="Please complete all fields before clicking the > Submit button" > > return dict(form=form,vars=form.vars) > > I've wasted several hours going around in circles, hoping that I've > missing something really small (like on several other occasions), but > I've not been able to find or come up with any solutions. Any help > would be greatly appreciated. > > Thanks > > LB --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---