Roundup Tracker - Issues

Message4114

Author richard
Recipients ezio.melotti, richard
Date 2010-08-12.05:15:52
Message-id <1281590153.8.0.442078188881.issue2550663@psf.upfronthosting.co.za>
In-reply-to
That's quite the effort you've made to trace through some of the ickiest code in Roundup :-)

The data quality issue in the various *Property classes - in particular the Link and Multilink 
ones - should probably be handled at the templating level, rather than down in the database 
(potentially masking other bugs).

To that end I think it's reasonable to have make_sort_function() do the right thing. It should 
*expect* to be passed lists with mixed content (ids and labels). I think a reasonable solution 
could be:


def make_sort_function(db, classname, sort_on=None):
    """Make a sort function for a given class.
    
    The list being sorted may contain mixed ids and labels.
    """
    linkcl = db.getclass(classname)
    if sort_on is None:
        sort_on = linkcl.orderprop()
    def sortfunc(a, b):
        if num_re.match(a):
            a = linkcl.get(a, sort_on)
        if num_re.match(b):
            b = linkcl.get(b, sort_on)
        return cmp(a, b)
    return sortfunc
History
Date User Action Args
2010-08-12 05:15:53richardsetmessageid: <1281590153.8.0.442078188881.issue2550663@psf.upfronthosting.co.za>
2010-08-12 05:15:53richardsetrecipients: + richard, ezio.melotti
2010-08-12 05:15:53richardlinkissue2550663 messages
2010-08-12 05:15:52richardcreate