The problem is that I need to change the problem line from:
246:    if attch.Addl_info_item.Email_text:

to:
246:    if attch.Email_text:

My previous 'select' statements retrieved fields from several tables, while 
this one (the 'problem' one) retrieves from only one table. So, if I 
understand correctly, if my fields come from only one table I leave off the 
table name when 'addressing' the row, else I do use the table name. That 
seems 'unorthogonal'. Am I misunderstanding?

On Thursday, September 13, 2012 4:16:44 PM UTC-6, MichaelF wrote:
>
> I do a similar set of steps, yet one of the sets acts differently. I'm 
> trying to loop through a query return (Rows), but I'm obviously missing 
> something basic.
>
> I do a query and 'print' the return. Here's a snippet from my controller:
>
> line 144:
> instAttch = db((db.Meet.id == request.args(1)) &
>                (db.Addl_institution_info.Start_date < db.Meet.Start_date) &
>                (db.Addl_institution_info.End_date > db.Meet.Start_date) &
>                (db.Participant_team.Is_home_team)).select(
>                  db.Addl_info_item.ALL,
>                  join = [db.Participant_team.on(
>                            db.Meet.id == db.Participant_team.Meet),
>                          db.Team.on(db.Participant_team.Team == db.Team.id
> ),
>                          db.Institution.on(db.Team.Institution ==
>                             db.Institution.id),
>                          db.Addl_institution_info.on(
>                             db.Addl_institution_info.Institution ==
>                               db.Institution.id),
>                          db.Addl_info_item.on(db.Addl_info_item.id ==
>                            db.Addl_institution_info.Addl_info_item)])
>
> ...
> Later in the same function (displayed with line numbers):
> 240: print 'Start loop at 240; instAttch:\n'
> 241: print instAttch
> 242: for attch in instAttch:
> 243:    print 'attch:\n'
> 244:    #
> 245:    print attch
> 246:    if attch.Addl_info_item.Email_text:
>
> The output from line 241 looks like a Rows object to my rookie eye:
>
> Start loop at 240; instAttch:
>
>
> Addl_info_item.id,Addl_info_item.File_path,Addl_info_item.Email_text,Addl_info_i
> tem.Content_id,Addl_info_item.Internal_description
> 2,C:\Users\mjf\Documents\MJF\WebSite\NCAA\private\Test DU Parking 
> pass.dat,Test
> email text: addl_info_item 2,,item 2
>
> attch:
>
> <Row {'Internal_description': 'item 2', 'Addl_pool_info': <gluon.dal.Set 
> object
> at 0x05DAA4D0>, 'update_record': <function <lambda> at 0x05F158B0>, 
> 'Addl_instit
> ution_info': <gluon.dal.Set object at 0x05DAA6B0>, 'File_path': 
> 'C:\\Users\\mjf\
> \Documents\\MJF\\WebSite\\NCAA\\private\\Test DU Parking pass.dat', 
> 'Email_text'
> : 'Test email text: addl_info_item 2', 'Content_id': '', 'Addl_meet_info': 
> <gluo
> n.dal.Set object at 0x05DAA1F0>, 'id': 2, 'delete_record': <function 
> <lambda> at
>  0x05F15F30>}>
>
> I do a 'for ...' on instAttch at line 242 and get:
> <type 'exceptions.KeyError'> 'Addl_info_item'
>
> The traceback tells me it's at line 246:
>    if attch.Addl_info_item.Email_text:
>
> What am I missing?
>

-- 



Reply via email to