Mercurial > p > roundup > code
diff roundup/backends/back_anydbm.py @ 2318:fa2f7ba34399
merge from maint-0-7
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sun, 16 May 2004 09:35:50 +0000 |
| parents | c7f780c24a87 |
| children | 10fc45eea226 |
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py Sun May 16 09:23:18 2004 +0000 +++ b/roundup/backends/back_anydbm.py Sun May 16 09:35:50 2004 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.147 2004-05-12 22:27:17 richard Exp $ +#$Id: back_anydbm.py,v 1.148 2004-05-16 09:35:49 richard Exp $ '''This module defines a backend that saves the hyperdatabase in a database chosen by anydbm. It is guaranteed to always be available in python versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several @@ -1800,21 +1800,27 @@ finally: cldb.close() + # sort vals are inserted, but directions are appended, so reverse + directions.reverse() + if '-' in directions: # one or more of the sort specs is in reverse order, so we have # to use this icky function to sort def sortfun(a, b, directions=directions, n=range(len(directions))): for i in n: - if a[i] == b[i]: continue + if not cmp(a[i], b[i]): + continue if directions[i] == '+': + # compare in the usual, ascending direction return cmp(a[i],b[i]) else: + # compare in the reverse, descending direction return cmp(b[i],a[i]) # for consistency, sort by the id if the items are equal return cmp(a[-2], b[-2]) matches.sort(sortfun) else: - # sorting is in the normal direction + # sorting is in the normal, ascending direction matches.sort() # pull the id out of the individual entries
