On Jul 23, 2010, at 4:39 PM, Rob wrote: > Hi Massimo, > > Thanks, that is what I prefer as well.
There are MVC arguments for pushing the html into the view. But this example is an easy one in this regard. Most of my tables don't go straight from the database to the view. Rather, they get manipulated somewhat, adding links or classes that are a function of the control logic. I'm inclined to do that kind of work in the controller, and since some of that involves assigning classes to TH elements and the like, I end up generating the whole table there and passing it to the view, as in your view 1. > > On Jul 23, 2:08 pm, mdipierro <[email protected]> wrote: >> I tend to do it in the views but I would make it a rule s/would/wouldn't/ >> >> On Jul 23, 3:49 pm, Rob <[email protected]> wrote: >> >>> What is the preferred way you guys do things? >> >>> controller (this covers both examples): >>> def index(): >>> rows = db().select(db.Category.ALL) >>> table = TABLE() >>> for row in rows: >>> table.append(TR(row.name, A("Delete", _href=URL(r=request, >>> f='delete', args=row.id)))) >>> return dict(table=table, rows=rows) >> >>> view 1: >>> {{extend 'layout.html'}} >>> {{=table}} >> >>> ~~ OR ~~ >> >>> view 2: >>> {{extend 'layout.html'}} >>> <table> >>> {{for row in rows:}} >>> {{=TR(TD(row.name), A("Delete", _href=URL(r=request, f='delete', >>> args=row.id)))}} >>> {{pass}} >>> </table> >> >>> Maybe in this example it doesn't matter? If this is the case, when >>> does it matter? I'm just trying to get an idea of how everyone builds >>> their stuff. >> >>> Sorry for asking such basic questions... but I have no one else to >>> ask! :) >> >>> Thanks, >>> Rob

