Alex wrote:
* Edmund Lian <elian@inbrief.net> [2003-04-04 14:00:27 -0500]:

  
Cheetah:
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
with.
    

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. 

  
...Edmund.
    

Cheers,

Alex.


-------------------------------------------------------
This SF.net 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
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
Webware-discuss mailing list
Webware-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-discuss
  
MakeSummaryTable.py
##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__':
    go()

allServiceSummary.tmpl
<table>
#for $row in $table
<tr onmouseover="this.style.background='#C0C0C0';"
        onmouseout="this.style.background=''">
    #if $row[0]
            <td class="data" colspan="6">$row[0]</td>
    #else
    #for $item in $row
            <td class="data" align="right">$item</td>
    #end for
    #end if
</tr>
#end for
</table>

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.

-Aaron