Alex wrote:
* Edmund Lian <> [2003-04-04 14:00:27 -0500]:

Pros: Supports inheritance of UI and site-wide templates very well, once
you understand it. Easy on the eyes and fingers. Encourages separation of
code from interface, but can easily intermingle them if you want (why?)
Cons: Hard to figure out where errors are coming from at times since
tracebacks do not always indicate where the problem is. Hard to get started

Triple amen on the last one. Does anyone have some Cheetah code that
they could share with a beginner? All I need for my first project is to
pull data out of a comma separated values file and stick it into a
nicely formatted table that is generated differently based on the
criteria chosen (sorting by columns selection of columns). I would
really appreciate any pointers. 




This email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
Webware-discuss mailing list
##Make an HTML table from cvs data
import sys
from Cheetah.Template import Template

def go():
    import ASV
    asv = ASV.ASV()
    asv.input_from_file(r'd:\comsci\tables\allServiceSummary.csv', ASV.CSV(), has_field_names = 0)
    print "Starting Template Run"
    templateObj = Template(file="ServiceTypeSummary-All.tmpl", searchList=[{'table':asv}])
    print templateObj

if __name__ == '__main__':

#for $row in $table
<tr onmouseover="'#C0C0C0';"
    #if $row[0]
            <td class="data" colspan="6">$row[0]</td>
    #for $item in $row
            <td class="data" align="right">$item</td>
    #end for
    #end if
#end for

You can pretty much use any csv file for this.
(If this was a perl app, it would all fit on one line!)

Let me know if you need more, I have a Cheetah App that turns 15 csv tables into 150 html pages, but it was a one-shot app so its not pretty.