hey,
here is what I do with plugin_wiki (usually for automated reports, but
here is a simplified sample):
header = ['First_Name', 'Last_Name', 'Age', 'Description']
data = \
'''fred,Flintstone,32,always gets into trouble,
Barney,Rubble,33,is always willing to help Fred
On Thursday, March 3, 2011 4:26:19 PM UTC-5, Anthony wrote:
>
> On Thursday, March 3, 2011 4:19:06 PM UTC-5, pbreit wrote:
>>
>> Yeah, I got kind of lost, too. The thing that threw me off were "trs[] ="
>> and "tables[] =". The = sign is for assignment, not adding or appending.
>> Each "trs[] =
On Thursday, March 3, 2011 4:19:06 PM UTC-5, pbreit wrote:
>
> Yeah, I got kind of lost, too. The thing that threw me off were "trs[] ="
> and "tables[] =". The = sign is for assignment, not adding or appending.
> Each "trs[] =" is re-assigning the whole variable each time, overwriting
> anythi
Yea, for some reason I thought that 'tables[] = ' would append to the list. I'm
not sure which language that's from, but it doesn't matter now, as it is
certainly much more readable to me. Before, the view had a hacky way of
grouping the data into a table and I was confused about the meaning of
Yeah, I got kind of lost, too. The thing that threw me off were "trs[] ="
and "tables[] =". The = sign is for assignment, not adding or appending.
Each "trs[] =" is re-assigning the whole variable each time, overwriting
anything that was already there (if I'm not mistaken).
But building tables
After seeing all the other posts, I completely rewrote the whole thing. I
grouped the data in the controller so that entries on the same day will be in
the same list, making easier to put each day of entries into its own table. I
have really advanced the whole thing since my original post. Here
On Thursday, March 3, 2011 10:31:18 AM UTC-5, Ross Peoples wrote:
>
> I know that web2py has HTML helpers like TABLE(), TR(), etc, but how would
> I build a table in this way, while in a for loop? This is what I tried so
> far, but it fails so horribly I don't even know where the error is:
>
>
Thanks Joe, I was wondering about this.
On Mar 3, 2011, at 2:44 PM, Joe Barnhart wrote:
> One thing I find handy about the helper objects is that they can be
> treated as lists:
>
> {{t=TABLE()}}
> ...
> {{t.append(TR(val11,val12,val13))
> ...
> {{t.append(TR(val21,val22,val23))
> ...
> {{=t}}
One thing I find handy about the helper objects is that they can be
treated as lists:
{{t=TABLE()}}
...
{{t.append(TR(val11,val12,val13))
...
{{t.append(TR(val21,val22,val23))
...
{{=t}} <-- this is when the table is added to the response
Note that you also do not need to use TD objects specific
I probably could modulo the size of dict instead of using a counter but I
didn't take the time to figure that out. Any assistance on that?
And furthering my example, in that very same view I have another table that
displays the same set of items in grid format. Note I included a counter "i"
and a "modulo 4" to insert a to break it up into rows of 4
columns. Also note the logic that inserts a placeholder image if an image is
not p
On Thursday, March 3, 2011 11:44:41 AM UTC-5, Ross Peoples wrote:
>
> That was a very helpful example. Thank you. So using the web2py TABLE
> helpers is best used for creating simple, static tables where the rows
> aren't generated?
I think you should be able to build a table programmatically
Well, I wouldn't necessarily say that's the "web2py way". I just like to
keep the logic in my views minimal. For example, the virtual fields are
actually in the models which is also a good place to prepare your data.
One reason to limit logic in views is if you ever have graphic designers
worki
2011/3/3 Ross Peoples
> (...)But if the web2py way is to format in the controller and make the
> views contain as little Python code as possible, then that's they way I'll
> write it.
>
> is not web2py's way, is MVC (Model-View-Controller) paradigm. it's all
about separating logic from what end u
That was a very helpful example. Thank you. So using the web2py TABLE helpers
is best used for creating simple, static tables where the rows aren't
generated? I guess that's ok, I always thought that the controller was meant to
get the data, while the views format the data. But if the web2py way
I usually try to put less logic in my views. For one, I try to assemble all
the data fields ahead of time either in the controller or with virtual
fields.
Then in the view, I try to just end up looping through the dict. I normally
use HTML tags but using Web2py tag helpers should be fine as wel
16 matches
Mail list logo