Changeset 2979 in products


Ignore:
Timestamp:
Nov 5, 2010 12:23:56 PM (13 years ago)
Author:
mylan
Message:

#228: Remake filterOut method of into generator for default filters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonegooglesitemaps/branches/blacklist/quintagroup/plonegooglesitemaps/filters.py

    r2939 r2979  
    1414    def filterOut(self, fdata, fargs): 
    1515        """Filter-out fdata list by id in fargs.""" 
    16         return [b for b in fdata if (b.getId or b.id) != fargs] 
     16        for b in fdata: 
     17            if (b.getId or b.id) != fargs: 
     18                yield b 
    1719 
    1820 
     
    2830    def filterOut(self, fdata, fargs): 
    2931        """Filter-out fdata list by path in fargs.""" 
     32        if not (fargs.startswith("/") or fargs.startswith("./")): 
     33            for b in fdata: 
     34                yield b 
     35             
    3036        if fargs.startswith("/"): 
    3137            # absolute path filter 
    32             portal = queryMultiAdapter((self.context, self.request), 
    33                          name=u"plone_portal_state").portal() 
    34             return [b for b in fdata if b.getPath() != '/%s%s' % (portal.getId(), fargs)] 
    35         elif fargs.startswith("./"): 
     38            portal_id = queryMultiAdapter((self.context, self.request), 
     39                         name=u"plone_portal_state").portal().getId() 
     40            test_path = '/' + portal_id + fargs 
     41        else: 
    3642            # relative path filter 
    37             contpath = '/'.join(self.context.getPhysicalPath()[:-1]) 
    38             return [b for b in fdata if b.getPath() != (contpath + fargs[1:])] 
    39         return fdata 
     43            container_path = '/'.join(self.context.getPhysicalPath()[:-1]) 
     44            test_path = container_path + fargs[1:] 
     45 
     46        for b in fdata: 
     47            if b.getPath() != test_path: 
     48                yield b  
     49 
Note: See TracChangeset for help on using the changeset viewer.