If you can do JOINS (not on GAE)

  rows = db(db.reply.task==db.task.id)
(db.task.created_by=auth.user.id).select(db.reply.ALL)

else (on GAE)

  task_ids = [task.id for task in
db(db.task.created_by=auth.user.id).select(db.task.id)]
  rows = db(db.reply.belongs(task_ids)).select()

either case

  for row in rows: print row.body

On Jul 21, 4:09 am, David Marko <dma...@tiscali.cz> wrote:
> Hello, I have two simple tables:
> db.define_table('task',
>                 Field('subject','string',label='Název'),
>                 Field('body','text', label='Podrobný popis'),
>                 Field("created_by",db.auth_user, writable=False,
> readable=True, default=auth.user_id, label='Autor')
> )
>
> db.define_table('reply',
>                 Field('body','text', requires=IS_NOT_EMPTY(),
> label='Popis'),
>                 Field("task", db.task, label='Úkol', notnull=True,
> writable=False, readable=False ),
> )
>
> How to specify DAL query to get all replies (table 'reply') that
> belongs to tasks(table 'task') which are created by currently logged
> user.
> (see relationship above: reply belongs to task, task has 'created_by'
> field which is the user id.)
>
> Thank you,
> David

Reply via email to