In db.py I defined the following tables:

db.define_table('company',
    Field('company',length=54,default='',notnull=True),
    migrate=False)

db.define_table('application',
 
Field('application',length=24,default='',notnull=True,unique=True),
    migrate=False)

db.define_table('companyapplication',
 
Field('company',db.company,default='',notnull=True,ondelete='CASCADE'),
 
Field('application',db.application,default='',notnull=True,ondelete='RESTRICT'),
    migrate=False)

db.companyapplication.company.requires=[IS_IN_DB(db,db.company.id,'%
(company)s'),IS_NOT_IN_DB(db(db.companyapplication.application==request.vars.application),db.companyapplication.company,error_message='combination
of company en application already in database')]
db.companyapplication.application.requires=IS_IN_DB(db,db.application.id,'%
(application)s')


In appadmin/insert/db/application I get the following error when I
want to insert an application:

Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py",
line 173, in restricted
    exec ccode in environment
  File "/Library/Python/2.5/site-packages/web2py/applications/base/
models/db.py", line 216, in <module>
 
db.companyapplication.company.requires=[IS_IN_DB(db,db.company.id,'%
(company)s'),IS_NOT_IN_DB(db(db.companyapplication.application==request.vars.application),db.companyapplication.company,error_message='combination
of company and application already in database')]
  File "/Library/Python/2.5/site-packages/web2py/gluon/sql.py", line
2424, in __eq__
    return Query(self, '=', value)
  File "/Library/Python/2.5/site-packages/web2py/gluon/sql.py", line
2839, in __init__
    right = sql_represent(right, left.type, left._db._dbname,
left._db._db_codec)
  File "/Library/Python/2.5/site-packages/web2py/gluon/sql.py", line
510, in sql_represent
    return str(int(obj))
ValueError: invalid literal for int() with base 10: 'Supplier'


I don't understand why I get an error on the validator of the
companyapplication table whereas I want to insert a record into the
application table.

What's causing this error? How do I solve it?


Kind regards,

Annet.


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en

Reply via email to