dear Massimo, I have solve the problem. I just had spell better. Just little mis- type.
Thank you and have a nice christmas and a fine good year. Matt On Dec 22, 4:08 pm, mattvangerwen <[email protected]> wrote: > Dear Massimo, > > First of all I want to thank you for such quick response. > > Herewith my partial code of my model: > > #kindofcontact > db.define_table('kindofcontact', > SQLField('catname','string', length=64, required=True), > SQLField('description','text'), > SQLField('createdon','datetime', default=now)) > > db.kindofcontact.catname.requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB > (db,'kindofcontact.catname')] > db.kindofcontact.createdon.requires=IS_DATETIME() > > #Person > db.define_table('person', > SQLField('catname', db.kindofcontact, required=True), > SQLField > ('lastname','string',length=32,default='',required=True,ondelete='CASCADE'), > SQLField('firstname', 'string',length=32,default=''), > SQLField('callingname','string',length=32,default=''), > SQLField('middlename','string',length=10), > SQLField('initials','string',length=32), > SQLField('createdon','datetime', default=now)) > > db.person.catname.requires=[IS_NOT_EMPTY(), IS_IN_DB > (db,'kindofcontact.id','%(catname)s')] > db.person.lastname.requires=[IS_NOT_EMPTY()] > db.person.initials.requires=[IS_NOT_EMPTY()] > db.person.createdon.requires=IS_DATETIME() > > #person address > db.define_table('address', > SQLField('person_id',db.person,required=True), > # SQLField('category','string',length=32), > SQLField('street','string',length=32,default=''), > SQLField('state','string',length=2,default=''), > SQLField('Postalcode','string',length=10,default=''), > SQLField('country','string',length=16, default=''), > SQLField('createdon','datetime', default=now)) > > As far as I see, I follow the thought/rule. I thouth that a possible > wrong drive could be the course. But I have checked my installation > and I have installed pscopg2 version 2.07. > > Further what I discovered was that the following wil work. (which > should) > db.person.catname.requires=[IS_NOT_EMPTY(), IS_IN_DB > (db,'kindofcontact.id','id' )] > > Thanks in advance. > > Matt van Gerwen > > On Dec 22, 2:09 pm, mdipierro <[email protected]> wrote: > > > Hi Matt, two issues > > > 1) > > db.person.catname.requires=[IS_NOT_EMPTY(), IS_IN_DB > > (db,'kindofcontact.id','%(catname)s')] > > > should be if you want a dropbox. > > > db.person.catname.requires=IS_IN_DB(db,'kindofcontact.id','% > > (catname)s') > > > 2) the error you are getting is very strange. Your database seems to > > return 'ANZN' for a field that is supposed to be integer. > > Are you sure person.catname is a referece to kindofcontact.id? > > > If not and you are actually trying to store the kindofcontact.catname > > in person.catname than this should be > > > db.person.catname.requires=IS_IN_DB(db,'kindofcontact.catname') > > > Massimo > > > On Dec 22, 6:30 am, mattvangerwen <[email protected]> wrote: > > > > Hi, > > > > I'm new to web2py. Even though I like to have postgresl as database. > > > For a crm application and later on for an casemanager application, I > > > like to several category-tables. For example a person can have > > > multiple phone-numbers for different companies. In SQLite it is > > > possible to select a value by name instead by id-number. However this > > > does not work with a Postgresql database, with the following statement > > > I get an error > > > db.person.catname.requires=[IS_NOT_EMPTY(), IS_IN_DB > > > (db,'kindofcontact.id','%(catname)s')] > > > > The error is: > > > What should I do to solve this? > > > > Traceback (most recent call last): > > > File "/idata/development/web2py/gluon/restricted.py", line 62, in > > > restricted > > > exec ccode in environment > > > File "/idata/development/web2py/applications/webCRM/controllers/ > > > appadmin.py", line 196, in <module> > > > File "/idata/development/web2py/gluon/globals.py", line 55, in > > > <lambda> > > > self._caller=lambda f: f() > > > File "/idata/development/web2py/applications/webCRM/controllers/ > > > appadmin.py", line 53, in insert > > > if form.accepts(request.vars,session): > > > File "/idata/development/web2py/gluon/sqlhtml.py", line 172, in > > > accepts > > > ret=FORM.accepts(self,vars,session,formname,keepvalues) > > > File "/idata/development/web2py/gluon/html.py", line 490, in accepts > > > status=self._traverse(status) > > > File "/idata/development/web2py/gluon/html.py", line 136, in > > > _traverse > > > newstatus=c._traverse(status) and newstatus > > > File "/idata/development/web2py/gluon/html.py", line 136, in > > > _traverse > > > newstatus=c._traverse(status) and newstatus > > > File "/idata/development/web2py/gluon/html.py", line 136, in > > > _traverse > > > newstatus=c._traverse(status) and newstatus > > > File "/idata/development/web2py/gluon/html.py", line 136, in > > > _traverse > > > newstatus=c._traverse(status) and newstatus > > > File "/idata/development/web2py/gluon/html.py", line 139, in > > > _traverse > > > newstatus=self._validate() > > > File "/idata/development/web2py/gluon/html.py", line 366, in > > > _validate > > > value,errors=validator(value) > > > File "/idata/development/web2py/gluon/validators.py", line 160, in > > > __call__ > > > if len(self.dbset(field==value).select(limitby=(0,1))): > > > File "/idata/development/web2py/gluon/sql.py", line 922, in __eq__ > > > def __eq__(self,value): return SQLQuery(self,'=',value) > > > File "/idata/development/web2py/gluon/sql.py", line 1065, in > > > __init__ > > > right=sql_represent(right,left.type,left._db._dbname) > > > File "/idata/development/web2py/gluon/sql.py", line 261, in > > > sql_represent > > > if fieldtype[0]=='i': return str(int(obj)) > > > ValueError: invalid literal for int() with base 10: 'ANZN' --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

