Hi Oskari 1. Your custom auth_user table should be declared before the line: auth.define_tables()
2. As 'accounts' table is referenced in your auth_user table, this should be declared prior to auth_user. I think you should be able to figure out anything else from the error tickets. See how it goes! Regards, D On Feb 16, 9:26 pm, Oskari <[email protected]> wrote: > Here's my code: > > db.py: > db.define_table( > "accounts", > Field("name","string",length=128,default=''), > Field("email","string",length=128,default=''), > Field('username', length=128,default='',unique=True), > Field('password', 'password', length=512, readable=False, > label='Password') > ) > > db.accounts.name.requires = IS_NOT_EMPTY() > db.accounts.password.requires = CRYPT(key=auth.settings.hmac_key) > > db.define_table( > "mytextbase", > Field("mytext","string",length=512,default=''), > Field("accountid",db.accounts) > ) > > db.mytextbase.accountid.requires = IS_IN_DB(db,"accounts.id") > > #Custom user-table to set accountid > db.define_table( > auth.settings.table_user_name, > Field('first_name', length=128, default=''), > Field('last_name', length=128, default=''), > Field('email', length=128, default='', unique=True), > Field('username', length=128,default='',unique=True), > Field('password', 'password', length=512, readable=False, > label='Password'), > Field('registration_key', length=512, > writable=False, readable=False, default=''), > Field('reset_password_key', length=512, > writable=False, readable=False, default=''), > Field('registration_id', length=512, > writable=False, readable=False, default=''), > Field('accountid', db.accounts) > ) > > custom_auth_table = db[auth.settings.table_user_name] > custom_auth_table.first_name.requires = > IS_NOT_EMPTY(error_message=auth.messages.is_empty) > custom_auth_table.last_name.requires = > IS_NOT_EMPTY(error_message=auth.messages.is_empty) > custom_auth_table.password.requires = [CRYPT()] > custom_auth_table.email.requires = [ > IS_EMAIL(error_message=auth.messages.invalid_email), > IS_NOT_IN_DB(db, custom_auth_table.email)] > > and my control.py: > def add(): > form=SQLFORM(db.mytextbase) > request.vars.accountid = session.auth.user.accountid > if form.accepts(request.vars,session): > response.flash = "Added successfully! :)" > elif form.errors: > response.flash = "Something went wrong! :(" > else: > response.flash = "Fill the form!" > return dict(form=form) > > With these my form only complains that accountid is:nt found in the > database > > On Feb 16, 10:19 pm, villas <[email protected]> wrote: > > > It should be easy. Post your relevant model and controller code. > > > BTW it probably doesn't make any difference... but maybe you might > > consider using the notation account_id instead of accountID. I read > > somewhere that some databases have case sensitive fields and that > > web2py makes some assumptions about this. Just better to work all in > > lowercase and avoid hitting that possible complication in the > > future. :) > > > Regards, D > > > On Feb 16, 6:47 pm, Oskari <[email protected]> wrote: > > > > I'm still struggling with the IS_IN_DB-validator. This problem occurs > > > when trying to implement reference id for example via a controller > > > line: > > > request.vars.reftableid = 2 > > > > The form just informs it isn't in the database. Why is that? > > > > On Feb 13, 3:14 pm, Oskari <[email protected]> wrote: > > > > > Uncommenting that did the trick. Perhaps there was something wrong > > > > with that =) > > > > > Anyways, thanks! > > > > > On Feb 13, 3:17 am, villas <[email protected]> wrote: > > > > > > Try commenting out the line 'custom_auth_table.accountID.requires...' > > > > > If that doesn't give you any progress, post all your auth model. I'm > > > > > sure someone should be able to spot something obvious -- these bugs > > > > > can be right under our noses sometimes :) > > > > > -D > > > > > > On Feb 12, 11:03 pm, Oskari <[email protected]> wrote: > > > > > > > Thank you for your answer villas! > > > > > > > I don't think that is the problem. I am able to make inserts through > > > > > > the appadmin-site, but somehow it fails with form.accepts(). > > > > > > I also tried what you suggested, but could not quite get it working. > > > > > > > On Feb 12, 8:45 pm, villas <[email protected]> wrote: > > > > > > > > Not sure, but the 3rd attrib of 'IS_IN_DB' doesn't look right? > > > > > > > > Maybe if you tried something like this, e.g. > > > > > > > custom_auth_table.accountID.requires = > > > > > > > IS_IN_DB(db,db.accounts.id,'% > > > > > > > (name)s') > > > > > > > > On Feb 12, 1:28 pm, Oskari <[email protected]> wrote: > > > > > > > > > Hi! > > > > > > > > > I'm having trouble making an insert with form.accepts() > > > > > > > > > Currently I have a custom auth_user that has one extra field: > > > > > > > > Field('accountID', db.accounts) with > > > > > > > > custom_auth_table.accountID.requires = > > > > > > > > IS_IN_DB(db,db.accounts.id,id) > > > > > > > > > While trying to modify variables it fails with "not found in db" > > > > > > > > > def func(): > > > > > > > > form=SQLFORM(db.auth_user) > > > > > > > > request.vars.accountID = 1 > > > > > > > > if form.accepts(request.vars,session): > > > > > > > > response.flash = "Succesfully created user" > > > > > > > > return dict(form=form) > > > > > > > > > Why does not form.accepts() recognize and accept my accountID? > >

