On Wed, Jan 13, 2010 at 2:07 PM, Alexandre Andrade
<[email protected]> 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 [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.