[ZPT] Two column ZPT output from SQL
    Duane Raymond 
    duane.raymond at gmail.com
       
    Tue Oct  5 07:59:54 EDT 2004
    
    
  
I think I'm trying to walk when I've just learned to crawl (with python)   :-(
> 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']
> 
I've tried 20-30 variations of what is suggested above and all I get
is 'attribute errors'.  Can you see anything wrong with the code
below:
columns=2 # the number of columns needed
query = "sql_getCountryGroupings()"
myObject = getattr(context,query)
qresults=context.myObject.dictionaries()
# this is done to get a real list
return [qresults[index:index+columns] for index in
range(0,len(qresults),columns)]
Sorry for being a bit slow - I'll post the final solution for others
once (if) I solve this.
Duane
    
    
More information about the ZPT
mailing list