[web2py] Re: How to represent dynamic fields in table

2013-12-25 Thread Anthony
The problem is that a set comprehension is being used, when it should be a list comprehension. Instead of: *{Field(name,...) for name in fields} it should be: *[Field(name,...) for name in fields] Anthony On Wednesday, December 25, 2013 5:39:43 AM UTC-5, Simon Ashley wrote: > > On a related

[web2py] Re: How to represent dynamic fields in table

2013-12-25 Thread Simon Ashley
On a related note, is there a way to control the order/ sequence of the generated fields? (i.e. each time the model is run, generated fields will be returned in a different order) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Sour

[web2py] Re: How to represent dynamic fields in table

2013-12-23 Thread Anthony
That's just Python. When the lambda's are called, they get the value of name from the scope in which they were defined, so all the lambdas will use the last value of name, which is the last month. Instead, you should pass in name as an argument to each lambda, which will put it in the scope of

[web2py] Re: How to represent dynamic fields in table

2013-12-23 Thread P T
Thank you Anthony, that worked like a charm. Is this technique I should learn in Python or Web2Py? PT On Monday, December 23, 2013 3:17:56 PM UTC-6, Anthony wrote: > > Try: > > lambda value, row, name=name: ... > > Anthony > > On Monday, December 23, 2013 11:38:08 AM UTC-5, P T wrote: >> >> I am

[web2py] Re: How to represent dynamic fields in table

2013-12-23 Thread Anthony
Try: lambda value, row, name=name: ... Anthony On Monday, December 23, 2013 11:38:08 AM UTC-5, P T wrote: > > I am using the following for "represent" fields in the table: > *{Field(name, 'integer', default=0, represent = lambda value, row: DIV(value > if value else '-',_class='month', _id=str(