I found a solution :
db.table1.registry_id.represent=\
lambda value: (value!=None and '%(num)s' %db.ref_registry[value]) or
'None'
Richard
2010/9/7 Richard Vézina <[email protected]>
> Hello,
>
> I have records that have field that refered to other table id, but sometime
> no refering id needed. In these case my app break, I mean when the foreign
> key field is empty.
>
> Here example :
>
> db.table1.registry_id.requires =
> IS_NULL_OR(IS_IN_DB(db,'ref_registry.registry_id',db.ref_registry._format))
>
> and I got this error when registry_id is empty :
>
> lambda id: db.ref_registry(id).num
> AttributeError: 'NoneType' object has no attribute 'num'
>
> Richard
>