[Zope-DB] ZPT SQL newbie question

Dieter Maurer dieter at handshake.de
Fri Sep 19 15:32:10 EDT 2003


Ray Kimsey wrote at 2003-9-18 19:56 -0400:
 > I have two questions that I expect are fairly simple to resolve, but all 
 > my searches have not ended in a solution. If you can point me in the 
 > right direction I would be most appreciative.
 > 
 > I have a SQL table similar to following:
 > 
 > focus_area_title   objective_text   initiative
 > ----------------------------------------------
 > Focus Area 1      Objective 1 text      ssf
 > Focus Area 2      Objective 2 text      ssf
 > Focus Area 2      Objective 3 text      ssf
 > Focus Area 3      Objective 4 text      dry

 > ...
 > that yields something like the following:
 > 
 >     Focus Area 1
 >         Objective 1 text
 > 
 >     Focus Area  2
 >         Objective 2 text
 > 
 >     Focus Area 2
 >         Objective 3 text
 > 
 > 
 > What I really want is:
 > 
 > 
 >     Focus Area 1
 >         Objective 1 text
 > 
 >     Focus Area  2
 >         Objective 2 text
 >         Objective 3 text
 > 
 > Does anyone know how to achieve this sort of  "group by" effect ?

Use a Python script to group the entries as necessary.
It should return a list of pairs "(areas, objectives_list)".



 > Part two is how to set the initiative argument to the ZSQL method  
 > (above it is hard coded to 'ssf') to the string value of  here/id.

Note: it is dangerous to append a tiny question to a bulky one.
It becomes then very easy to be overlooked.

You give your Z SQL Method an argument, say "initiative".
Then you call it by "myZSQLMethod(initiative='ssf')".


Dieter



More information about the Zope-DB mailing list