HTML template for database report

Michal Wallace (sabren) sabren at manifestation.com
Mon Feb 28 22:23:31 CET 2000


On Mon, 28 Feb 2000, Andrew Henshaw wrote:

> <report database="database" record_source="table or query">
> 
>   HTML here
> 
>     <group_header field="field 1" sort=ascending|descending>
>       some more HTML   
>     </group_header>
>     
>       <detail>
>         <item field="field 2"> <item field="field 3">
>       </detail>
> 
>     <group_footer>
>       some more HTML
>     </group_footer>
>   
>   some more HTML
>  
> </report>

Hello Andrew,

Well well well... I wasn't going to mention this until I got quite
a bit more done, but since you asked... http://zebra.sourceforge.net/
My version looks like this:

        * zebra
        ** source name="database" class="csv"
        .
        ** query name="myquery" source="database"
        testcsv.csv
        ** show
        Here is the report:
        
        ** report query="bubba"
        *** head
        HEADER!
        -------
        *** group field="lyric"
        **** head
        {guy} loves {girl}
        **** body
        ***** if test="{lyric}"
            a little bit of {girl} {lyric}
        *** foot
        -------
        FOOTER!


Given a comma seperated value file that looks like this:

        guy,girl,lyric
        fred,wilma,
        homer,marge,
        lou,everyone,
        lou,everyone,monica in my life
        lou,everyone,erica by my side
        lou,everyone,rita is all i need
        lou,everyone,tina is what i see
        lou,everyone,sandra in the sun
        lou,everyone,mary all night long
        lou,everyone,jessica here I am
        lou,everyone,you makes me your man

it prints:

        Here is the report:

        HEADER!
        -------
        fred loves wilma
        ... and wilma loves fred
        homer loves marge
        ... and marge loves homer
        lou loves everyone
            a little bit of monica in my life
            a little bit of erica by my side
            a little bit of rita is all i need
            a little bit of tina is what i see
            a little bit of sandra in the sun
            a little bit of jessica here i am
            a little bit of you makes me your man
        ... and everone loves lou
        -------
        FOOTER!


The * notation is just syntactic sugar for XML.. in fact, zebra
converts it to well-formed XML before processing..  (mixing html and
xml is messy and can lead to ill-formedness unless you change all the
</> to </>)

The end result is a script that does what you want.

It's written in python - but was my first python app,
so it's kind of messy.. I'm actively cleaning it up.

Also, it originally generated PHP3 code.. It still does,
but now I'm converting it to output other stuff,
like Python and ASP..

the "csv" module is just a dummy module I'm using for
testing. It uses a subset of the python database API,
so zebra is desiged to run reports off of anything..

There's a demo of it generating PHP3 that works as
the frontend to a search engine at http://www.linkwatcher.com/blogsearch/

By the way, I'm in Atlanta, too, and this technology is going to be
the cornerstone of a company I'm starting, so perhaps we ought to
talk?

Cheers,

- Michal
-------------------------------------------------------------------------
http://www.manifestation.com/         http://www.linkwatcher.com/metalog/
-------------------------------------------------------------------------





More information about the Python-list mailing list