Changeset 5172 for MILK


Ignore:
Timestamp:
06/04/09 10:11:39 (10 years ago)
Author:
cbyrom
Message:

Add filtering to discovery service for atoms - to only display atoms
in the 'published' or 'Published' state when in browse mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • MILK/trunk/milk_server/milk_server/controllers/browse/discovery.py

    r5158 r5172  
    407407        if isAtom: 
    408408            c.searchTerm = " - for search term, '%s'" %self.inputs['searchString'] 
     409            if not g.atomEditorEnabled: 
     410                c.results = self.__filterAtomResults(c.results) 
     411 
    409412            if c.results: 
    410413                c.searchTerm += ' [%s results found]' %len(c.results) 
     414                 
    411415                 
    412416            html = render('genshi', 'browse/short_atom_results') 
     
    417421            return render('browse/short_results') 
    418422 
     423 
     424    def __filterAtomResults(self, results): 
     425        ''' 
     426        Given a set of atom docs search results, filter these to only return docs in the 
     427        'published' or 'Published' state 
     428        @param results: list of results as returned by SearchClient 
     429        @return filteredResults: list of results with only published data included 
     430        ''' 
     431        logging.debug("Filtering results to remove non-published data") 
     432        filteredResults = [] 
     433        for result in results: 
     434            if result.collection.find('ublished') == -1: 
     435                logging.debug("- found non-published doc - ignoring") 
     436                continue 
     437            filteredResults.append(result) 
     438        logging.debug("- returning filtered results") 
     439        return filteredResults 
     440 
    419441             
    420442    def clearSession(self): 
Note: See TracChangeset for help on using the changeset viewer.