I don't really know,  but I would suggest playing around with things on the 
commandline.

python web2py.py -S yourapp -N -M

>>> rows = db(db.Addl_info_item.id > 0).select()
>>> for f in rows[0]: print f
>>> for r in rows: print r.Email_text

etc etc


You can put more and more code in there and hopefully see what's going 
wrong.

BTW  one thing I would advise against is using mixed case for table and 
field names.  Obviously it is easier to make typos if you have to worry 
about the case.  However I have also seen issues with certain DBs.  If that 
is something you can address,  then make everything lowercase,  it would 
probably make things much easier for you in the long run.

Regards,  D

On Thursday, September 13, 2012 11:16:44 PM UTC+1, 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