first of all: a simpler example reproducing the "erroneous" behaviour may pinpoint better the cause. To help debugging, I'd avoid truncating and reinserting records every time you land on index() Then, I have a question: what does it mean "only top rows from one table are updated" ?
On Wednesday, April 23, 2014 1:29:10 PM UTC+2, alex wrote: > > Hello guys, I'm experiencing an unexpected behavior using grid form with > selectable option, need help. > > I have a temporal table 'rogue_rows' in a database 'dyn_db'. This table > includes rows from different tables of another database. Please refer to > the controller index() code: > > def index(): > dyn_db.rogue_rows.truncate() > # truncate table each time index is called > > for table in tables_list : # table list contains needed tables. > query=(cam_db[table].trunk==0) & (cam_db[table].rogue==1) > rows = > cam_db(query).select() # > extract needed rows from current table > for row in rows : > # insert each row in temporal table > dyn_db.rogue_rows.insert(table_name=table, > node_name=row.node_name, > mac=row.mac, > port=row.port, > ) > > > grid=SQLFORM.grid(dyn_db.rogue_rows, # > convey dyn_db.rogue_rows table to the grid form > fields=[dyn_db.rogue_rows.node_name, > dyn_db.rogue_rows.mac, > dyn_db.rogue_rows.port], > selectable=lambda ids : > allow_mac(ids) # add checkboxes to each row, hand over > selected row ids to function allow_macs() > ) > return dict(grid=grid) > > The index() function works great, it displays all the rows from the > different tables. When I check all the boxes, let's say there were 5 rows, > and click submit - grid calls allow_macs() with ids = [1,2,3,4,5]. Until > now, it was all fine. Please refer to allow_mac() func: > > def allow_mac(ids) : > for id in ids : # iterate > over all checked row ids > query = dyn_db.rogue_rows.id == id > rows = dyn_db(query).select() # select each > selected row > for row in rows : > cam_db(cam_db[row.table_name].mac==row.mac).update(rogue=0) > # update rows in main tables > > The problem is when I check all the boxes and click submit, only top rows > from one table are updated, then I have to check remained rows again and > submit them as well - another top rows from another table will be updated > etc... I would like them to be updated all at once... > > I mentioned that if I comment truncate string, then it works but with a > flaw - if I refresh page the rows in temporal page duplicate each time. Any > ideas ?? > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

