The validators do not seem correct. Maybe try them separately:
Field('name',default='',notnull=True,unique=True),
Then after the table defined...
is_not_in_db=IS_NOT_IN_DB(db,'hub.name',error_message='name already in
database')
db.hub.name.requires= [IS_NOT_EMPTY(),is_not_in_db]
On Thursday, October 18, 2012 10:14:21 AM UTC+1, Annet wrote:
>
> I defined the following table:
>
> is_not_in_db=IS_NOT_IN_DB(db,'hub.name',error_message='name already in
> database')
>
> db.define_table('hub',
> Field(...),
>
> Field('name',default='',IS_NOT_EMPTY(),is_not_in_db],notnull=True,unique=True),
> ...
> migrate=False)
>
>
> ... and the following function:
>
> def update():
> form=SQLFORM.factory(db.hub,...)
> .... # prepopulate the form
> if form.process(keepvalues=False).accepted:
> ...
> is_not_in_db.set_self_id(hub.id)
> hub.update_record(**db.hub._filter_fields(form.vars))
> ..
> elif form.errors:
> response.flash=response_flash('formerror',session)
> elif not response.flash:
> response.flash='...'
> return dict(form=form)
>
> Despite the is_not_in_db validator and is_not_in_db.set_self_id(hub.id) I
> get an error on field name " name already in database". This used the work,
> is this no longer supported? What's the correct way to get this to work.
>
> Kind regards,
>
> Annet
>
--