Changeset 1751 for trunk/LeMillTool.py


Ignore:
Timestamp:
05/14/07 15:56:36 (12 years ago)
Author:
jukka
Message:

Worked on #1365, #1366. Spent 12h. Major refactoring of browsing views. Should be working except portfolios and tests. Code should be much, much clearer, less insane and faster.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LeMillTool.py

    r1745 r1751  
    678678            return True 
    679679 
     680    def prioritizeResults(self, results): 
     681        """ First by language:  
     682            1)selected user interface language 
     683            2)by user profile's language selections 
     684            3)english 
     685            4)others 
     686            secondary sort by points 
     687            """ 
     688        ilanguage=getToolByName(self, 'portal_languages').getLanguageCookie() 
     689        ulanguages=getToolByName(self, 'portal_membership').getHomeFolder().getLanguage_skills() 
     690 
     691        def compfunc(a,b): 
     692            # this looks stupid, but hopefully we don't have to go very far in those ifs per run. 
     693            al=a.Language 
     694            bl=b.Language 
     695            if al==ilanguage and bl!=ilanguage: 
     696                return -1 
     697            if al!=ilanguage and bl==ilanguage: 
     698                return 1 
     699            if al in ulanguages and bl not in ulanguages: 
     700                return -1 
     701            if al not in ulanguages and bl in ulanguages: 
     702                return 1 
     703            if al=='en' and bl!='en': 
     704                return -1 
     705            if al!='en' and bl=='en': 
     706                return 1 
     707            return cmp(b.score, a.score) 
     708             
     709        return results.sort(compfunc) 
     710         
     711                                 
     712 
     713 
    680714 
    681715InitializeClass(LeMillTool) 
Note: See TracChangeset for help on using the changeset viewer.