[ZPT] Two column ZPT output from SQL

Tino Wildenhain tino at wildenhain.de
Tue Oct 5 07:14:35 EDT 2004


Hi,

On Tue, 2004-10-05 at 12:52, Duane Raymond wrote:
> On Tue, 05 Oct 2004 11:53:59 +0200, Tino Wildenhain <tino at wildenhain.de> wrote:
> > Dont try to do this all in ZPT. It leads to very ugly code (as
> > shown above)
> > 
> > Use a pyton script to prepare the values:
> <snip>
> 
> Thanks Tino - worked like a charm.
> 
> I am now trying to generalise it so I can use the same python script
> for any SQLQuery-ZPT multi-column.  I've made columnwidth and
> queryname into parameters, but I can't seem to find a way to have the
> 'queryname' value (i.e. sql_getMyList() ) substituted in the line like
> :
> qresults=context.queryname.dictionaries() 
>     instead of:
> qresults=context.sql_getMyList().dictionaries()
> 
> Any further hints (I'm still scowering my 'learning python' book as well)

All you have to know is Objectmanagers (as for example Folders)
and many other zope objects support __getitem__ and __getattr__
meaning you can do both

getattr(container,'attributename') (also with default - see
help(getattr))

and container['attributename']

Regards
Tino



More information about the ZPT mailing list