annet
unread,Nov 17, 2010, 3:35:13 AM11/17/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
I set up a mock app to help someone solve a problem.
In db.py I defined these two tables after all the mail, auth and crud
stuff:
db.define_table('mockbio',
Field('unique_id',type='integer',unique=True,writable=False,readable=True),
Field('first_name',length=24),
Field('last_name',length=72),
migrate='mockbio.table')
db.mockbio.unique_id.default=auth.user_id
db.mockbio.unique_id.requires=IS_NOT_IN_DB(db,db.bio.unique_id)
db.mockbio.unique_id.label=T('Unique_id')
Using web2py's administrative interface I am able to enter a record
for each user I created, when I enter a second record for a user I get
an error on the unique_id field: value already in database or empty.
I also defined two functions in default.py:
@auth.requires_login()
def create_mockbio_first():
form=crud.create(table=db.mockbio)
return dict(form=form)
@auth.requires_login()
def create_mockbio_second():
form=SQLFORM(db.mockbio)
if form.accepts(request.vars, session):
session.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill the form'
return dict(form=form)
When I expose the functions, I can create a record for the logged in
user once, when I try to create a second record for the same user an
error ticket is issued: IntegrityError: column unique_id is not unique
Why do I get an error ticket instead of an error message in the form?
Kind regards,
Annet