Greetings Folks, I have a case were we have general index_html which is aquired by various subfolders, the crux of this index_html is a call to SQL, have a generic sql method that is called in each folder. This is all well and good until I need to specifically get some ordering to the values returned in my sql, 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, I need to return that rather than a mapping keyword in dtml-in as existing sql returns that kind of object (Shared...Results) and I dont want to override the index_html as I dont want to change two files if I make a modification. Currently my code looks something like this, def receiving_sql_select(self): invalid= [] valid = [] result = self.sql_select_all() resultdicts = result.dictionaries() for item in resultdicts: if int(item['status'])==3: invalid.append(item) else: valid.append(item) return invalid + valid I think I almost have it? Ideas/Suggestions appreciated Regards, Brenton Bills.
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
participants (2)
-
Brenton Bills -
Dieter Maurer