Let's make it clear: db.task -> child db.opportunity -> parent db.oppty_main_id -> grandparent
db.task.opportunity_id.represent=lambda opportunity_id: db.oppty_main_id[db.opportunity[opportunity_id].id].name should work db.task.opportunity_id.represent=lambda opportunity_id: db.opportunity[opportunity_id].name <http://oppty_main_id.name/> 2010/1/13 Miguel Lopes <mig.e.lo...@gmail.com> > On Wed, Jan 13, 2010 at 2:07 PM, Alexandre Andrade > <alexandrema...@gmail.com> wrote: > > this works for me: > > > > db.plano_aplicacao.codigo.represent= lambda codigo: > > db.natureza_despesa[codigo].codigo + ' - ' + > > db.natureza_despesa[codigo].especificacao ), > > ("Olá Alexandre" == "Hello Alexandre") > I'm not trying to get to a representation that is in the child table. > Rather it's in a grandchild table (in a another parent of the child > able to be exact). So the code should be something like: > > db.task.opportunity_id.requires=IS_NULL_OR( > IS_IN_DB(db(db.opportunity.id==db.task.opportunity_id), > 'opportunity.id')) > db.task.opportunity_id.represent=lambda opportunity_id: > db.opportunity[opportunity_id].oppty_main_id.name > > But this doesn't work. Although, I get the right result if (given > opportunity_id): > print db.opportunity[opportunity_id].oppty_main_id.name > > The models are [irrelevant fields removed]: > > db.define_table('task', > Field('title'), > Field('opportunity_id',db.opportunity,default=None)) > > db.task.opportunity_id.requires=IS_IN_DB(db,'opportunity.id') > db.task.opportunity_id.requires.zero='' > > > db.define_table('opportunity', > Field('oppty_main_id', db.oppty_main)) > > db.opportunity.oppty_main_id.requires=IS_IN_DB(db, 'oppty_main.id', > '%(name)s') > > > db.define_table('oppty_main', > Field('name', label='Oportunidade')) > > db.oppty_main.name.requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db,' > oppty_main.name')] > > Miguel > > -- > 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<web2py%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/web2py?hl=en. > > > > -- Atenciosamente -- ========================= Alexandre Andrade Hipercenter.com--
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.