[Zope] Shared.DC.ZRDB.Results

Dieter Maurer dieter@handshake.de
Wed, 29 Jan 2003 21:27:51 +0100


Brenton Bills wrote at 2003-1-29 17:05 +1000:
 > ....
 > therefore I have
 > created an external method that changes the ordering
 > in which the results are returned, but sadly I can't
 > figure out how to return a Shared.DC.ZRDB.Results object
 > to my dtml-in
 > ...
 > def receiving_sql_select(self):
 >     invalid= []
 >     valid = []
 > 
 >     result = self.sql_select_all()
 >     resultdicts = result.dictionaries()
Strange that people like the "dictionaries" method...

As you do not want to return dictionaries, do not use it!

 >     for item in resultdicts:
 >         if int(item['status'])==3:
 >               invalid.append(item)
 >         else:
 >               valid.append(item)
 >     return invalid + valid
I would use:

	for item in result: # "result" behaves like a sequence
	    if int(item.status) == 3:
	       invalid.append(item)
	    else:
	       valid.append(item)
	return invalid + valid



Dieter