I think i can explain this behaviour. The statement "var in list" cals the lists __contains__ method, which loops through the list and compares each element with var. But in case of an Field object the equals operator (__eq__) has another meaning, it's the "WHERE" part of the db query: db(db.table.id==1).select() So this comparison will olways return True.
Am Samstag, 20. Juli 2013 09:00:52 UTC+2 schrieb Massimo Di Pierro: > > Strange. Ok. I changed it again. Can you please check it. I am still > trying to avoid the double loop for every virtual table. > > On Friday, 19 July 2013 16:54:05 UTC-5, peckto wrote: >> >> Regarding your changes: >> + all_fields = filter(lambda nv: nv[1] in fields and >> + isinstance(nv[1],(FieldVirtual, >> FieldMethod)), >> + table.iteritems()) >> It doesn't work. It ends up in returning all virtual fields, even when >> they are not requested. >> It's because of the "var in list" statement: >> nv[1] in fields >> always returns True. I don't know why. >> >> Another solution would be to use the id() function: >> id(nv[1]) in [id(f_) for f_ in fields] >> but you have overwritten this function >> 2091: id = value >> >> So I came finally to the complicated looking statement: >> nv[0] in [f_.name for f_ in fields] and nv[1].tablename == tablename >> >> Maybe you can tell me why the "var in list" statement fails >> or we use one of the other solutions (while renaming the id value). >> > -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.