[Chicago] python and reports

Martin Maney maney at two14.net
Fri Dec 14 04:21:29 CET 2007


On Thu, Dec 13, 2007 at 03:36:29PM -0600, Lukasz Szybalski wrote:
> Right now I just need to print a formatted page(complex letter style
> page). Something similar to merge fields and word documents would work
> but through python. My data is in tag file, so I have key and value
> that I could pass in.

So what you're saying is the template is one big honkin' string, you
turn the tag file into a dict, and

print template % tag_dict

(hmmm, that started out as tongue in cheek, but now that I think about
it I would have killed for something like that that was so simple to
implement, oh, about twenty years ago.  ended up doing a variation on
that theme in C, which was about as painful as you imagine it would
be.)

> So I'm either thinking of using xhtml or rtf to create my page layout
> and then use cheetah to fill in these values. I know cheetah will work
> for xhtml, I don't know about rtf.

Django's templates are quite happy producing output other than HTML,
since they aren't really at all HTML specific (other than perhaps a
fine disregard for leaving meaningless whitespace in the output). 
Jinja began as a separate-from-Django version of Django's template
engine (more or less), but seems to have since evolved in the direction
of the PHP error (embed your code in the template!  make it all one
great steaming mess!  say, what was the point of replacing print
statements with a separate template, again?).

Just sketching on recycled paper here...

-- 
Writing blog entries is like tapping out a tune on a piano,
or drawing a little sketch on newsprint.  Writing a book is
closer to painting a mural or composing an opera.  -- Charles Petzold



More information about the Chicago mailing list