In my model I have a combination table that combines companies with activities. Since I don't want a user to enter a combination twice I defined the following validator:
db.companyactivity.company.requires=[IS_IN_DB(db,db.company.id,'% (companyname)s'),IS_NOT_IN_DB(db (db.companyactivity.activity==request.vars.activity),db.companyactivity.company,error_message='already in database')] I also have a table timetable which reads like: db.define_table('timetable', Field ('company',db.company,default='',notnull=True,ondelete='CASCADE', writable=False, readable=False), Field('activity',length=48,default='',notnull=True), Field('day',db.dag,default='',notnull=True,ondelete='RESTRICT'), Field('time',type='time',default='',notnull=True), Field('duration',length=3,default='',notnull=True), Field('location',length=24), Field ('level',db.level,default=1,notnull=True,ondelete='RESTRICT'), migrate='timetable.table') In my cms the function to insert a class or update a class reads like: @auth.requires_membership('site_manager') def create_timetable(): response.view='default/form.html' response.flash='Insert class' db.timetable.company.default=auth.user.company activity=activity_rowset() db.timetable.activity.requires=IS_IN_SET([row.activity for row in activity]) form=create_form(db.timetable,message='Class inserted') return dict(form=form) @auth.requires_membership('site_manager') def update_timetable(): response.view='default/form.html' response.flash='Update or delete class' record=db.timetable[request.args[0]] if not record or not record.company==auth.user.bedrijf: redirect(URL(r=request,f='crud_timetable')) activity=activity_rowset() db.timetable.activity.requires=IS_IN_SET([row.activity for row in activity]) form=update_form(db.timetable,record,'crud_timetable','Class deleted or updated',True) return dict(form=form) When I expose these function I get the following error ticket: Traceback (most recent call last): File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py", line 184, in restricted exec ccode in environment File "/Library/Python/2.5/site-packages/web2py/applications/cms/ models/db.py", line 293, in <module> db.bedrijfactiviteit.bedrijf.requires=[IS_IN_DB(db,db.bedrijf.id,'% (bedrijfsnaam)s'),IS_NOT_IN_DB(db (db.bedrijfactiviteit.activiteit==request.vars.activiteit),db.bedrijfactiviteit.bedrijf,error_message='combinatie bedrijf en activiteit al in database')] File "/Library/Python/2.5/site-packages/web2py/gluon/sql.py", line 2310, in __eq__ return Query(self, '=', value) File "/Library/Python/2.5/site-packages/web2py/gluon/sql.py", line 2688, in __init__ right = sql_represent(right, left.type, left._db._dbname) File "/Library/Python/2.5/site-packages/web2py/gluon/sql.py", line 466, in sql_represent return str(int(obj)) ValueError: invalid literal for int() with base 10: 'BodyCircuit' When I remove the validator from the companyactivity table, both functions work for the timetable table work. I don't see the connection between the validator and the two functions, therefore I don't understand why this error occurs. Does one of you know why this happens? Kind regards, Annet. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@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.