Update: Following christian's example, it seems that looping over the Rows object in controller does nothing, but looping over it on the view is working.
My controllers and models are almost exactly the same, at least the fields that are affected. I am testing on localhost:8080 first, although same results in GAE production. I print out stuff on localhost:8080, it works although it breaks the page and displays withing <pre> tags (ala php die ;-P), so I can see variables. I can see the Rows object and the fetched records, but when I iterate over them nothing happens. # controller profiles = db(db.userprofile.created).select(orderby=~db.userprofile.created, limitby=(0,20)) print profiles # no problem, I see the profiles object print len(profiles) # still OK for profile in profiles: print profile # here nothing happens # view <h1>profiles</h1> {{for profile in profiles:}} {{=profile.title}}<br /> {{pass}} Now I'm not sure if this is a bug, but I would appreciate a way for me to make it work on the controller side because I'll need to fetch stuff that spans a couple of tables, and that would nicely fit in the controller instead of the view. Thanks, Arbie On Aug 29, 3:24 am, howesc <how...@umich.edu> wrote: > here is what i just tried: > > db.define_table('menu_item', > Field('created_on','datetime', default=request.now,writable=False), > Field('name', length=500, notnull=True, unique=True, > requires=IS_NOT_IN_DB(db, 'menu_item.name')), > migrate=migrate) > > then in controller: > > def index(): > > data=db(db.menu_item.created_on).select(orderby=~db.menu_item.created_on, > limitby=(0,20)) > > data2=db().select(db.menu_item.ALL,orderby=~db.menu_item.created_on, > limitby=(0,20)) > > return dict(data=data, data2=data2) > > then in view: > > {{=BEAUTIFY(response._vars)}} > > <h1>data</h1> > {{for d in data:}} > {{=d.name}}<br /> > {{pass}} > > <hr /> > <h1>data2</h1> > {{for d in data2:}} > {{=d.name}}<br /> > {{pass}} > > and got exactly what i was expecting. some things i noticed: > - i don't think db(db.menu_item.created_on) is a valid query. it needs to > be compared to something right? (i know it works, but it seems wrong to me) > - print doesn't work on GAE (there is no console to output to in that > environment) so i assumed you were either using logging or outputting in a > view > > can you tell me more, or send me a minimal application that produces the > problem and i'll try it out too? it sounds like something is up, so let's > get to the bottom of it and get it fixed! > > christian On Aug 29, 3:24 am, howesc <how...@umich.edu> wrote: > here is what i just tried: > > db.define_table('menu_item', > Field('created_on','datetime', default=request.now,writable=False), > Field('name', length=500, notnull=True, unique=True, > requires=IS_NOT_IN_DB(db, 'menu_item.name')), > migrate=migrate) > > then in controller: > > def index(): > > data=db(db.menu_item.created_on).select(orderby=~db.menu_item.created_on, > limitby=(0,20)) > > data2=db().select(db.menu_item.ALL,orderby=~db.menu_item.created_on, > limitby=(0,20)) > > return dict(data=data, data2=data2) > > then in view: > > {{=BEAUTIFY(response._vars)}} > > <h1>data</h1> > {{for d in data:}} > {{=d.name}}<br /> > {{pass}} > > <hr /> > <h1>data2</h1> > {{for d in data2:}} > {{=d.name}}<br /> > {{pass}} > > and got exactly what i was expecting. some things i noticed: > - i don't think db(db.menu_item.created_on) is a valid query. it needs to > be compared to something right? (i know it works, but it seems wrong to me) > - print doesn't work on GAE (there is no console to output to in that > environment) so i assumed you were either using logging or outputting in a > view > > can you tell me more, or send me a minimal application that produces the > problem and i'll try it out too? it sounds like something is up, so let's > get to the bottom of it and get it fixed! > > christian