"english logic": a chart named 'abc' is mine if there is a record in the 
'user_chart' table whose id_user is my user_id and has a chart_id equal to 
the id of the 'chart' table whose chartName is 'abc'

DAL syntax:
db(
    (db.user_chart.id_user == auth.user_id) & ##all charts of the user
    (db.chart.chartName == 'abc') & ##all charts named 'abc'
    (db.user_chart.id_chart == db.chart.id) ##the actual relation
).select()




On Wednesday, November 7, 2012 5:30:42 PM UTC+1, Simon Carr wrote:
>
> Hi All,
>
> I have these 3 tables among others
>
> db.define_table('workbook',
> Field('path',requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'workbook.path')]),
> Field('title',requires=IS_NOT_EMPTY()),
> format="%(title)s",
> )
>
>
> db.define_table('chart',
> Field('chartName'),
> Field('id_workbook',db.workbook),
> Field('worksheet'),
> Field('file','upload'),
> format="%(id_workbook)s %(chartName)s",
> )
>
> db.define_table('user_chart',
>
> Field('id_user',db.auth_user,writable=False,readable=False,default=auth.user_id),
> Field('id_chart','reference chart'),
> Field('title'),
> Field('description','text'),
> format="%(title)s",
> )
>
> I have setup a function in my modal 
>
> def is_my_chart(chartname):
>     if db((db.user_chart.id_user == auth.user_id) & 
> (db.user_chart.id_chart.chartName == chartname)).count() > 0:
>         return True
>     else:
>         return False
>
> But I get the following error
>
> AttributeError: 'Field' object has no attribute 'chartName'
>
>
> How do I fetch the fields out of a joined table?
>
> Thanks
> Simon
>
>

-- 



Reply via email to