Changeset 2916 in products
- Timestamp:
- Oct 22, 2010 11:38:57 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonegooglesitemaps/branches/blacklist/quintagroup/plonegooglesitemaps/browser/commonview.py
r2742 r2916 1 1 from string import find 2 2 from zope.interface import implements, Interface, Attribute 3 from zope.component import queryUtility 3 4 4 5 from Acquisition import aq_inner, aq_parent … … 7 8 8 9 from quintagroup.plonegooglesitemaps import qPloneGoogleSitemapsMessageFactory as _ 10 from quintagroup.plonegooglesitemaps.config import BLACKOUT_PREFIX 11 from quintagroup.plonegooglesitemaps.interfaces import IBlackoutFilterUtility 9 12 from quintagroup.plonegooglesitemaps.browser.utils import additionalURLs, applyOperations 10 13 … … 68 71 result = [] 69 72 objects = self.getFilteredObjects() 70 blackout_list = self.context.getBlackout_list()71 73 reg_exps = self.context.getReg_exp() 72 74 73 brain_url_map = applyOperations([ob for ob in objects 74 if (ob.getId not in blackout_list)], 75 reg_exps) 76 75 brain_url_map = applyOperations(self.getBOFiltered(objects), reg_exps) 77 76 # Prepare dictionary for view 78 77 for url, b in brain_url_map.items(): … … 82 81 self.num_entries = len(result) 83 82 return result 83 84 def getBOFiltered(self, objects): 85 """Return blkack-out filtered objects 86 Every record in blackout_list filter should follow the spec: 87 [extra filter data, separated by ':':][<filter name>:]<filter data> 88 For example: 89 1| index.html 90 2| id:index.html 91 3| path:/folder_1_level/obj_in_folder 92 4| path:./folder_near_sitemap/obj_in_folder 93 5| extra_arg1:extra_arg2:super_filter:super arg-1, super arg-2 94 95 1->used default "id" filter - remove "index.html" objects; 96 2->explicit "id" filter - remove "index.html" objects; 97 3->"path" filter - remove /folder_1_level/obj_in_folder object, 98 path from the root of the plone site; 99 4->same to 3), but path get from the folder, where sitemap is located; 100 5->filter name is "super_filter" (must be registered IBlackoutFilterUtility, 101 named "seoptimzier.blackoutfilter.super_filter:), which get list of extra 102 parameters, e.g. [extra_arg1,extra_arg2] to the filterOut method in 103 "extras" option, and get filter arguments: super arg-1, super arg-2 104 105 class SuperFilterUtility(object): 106 def filterOut(self, fdata, fargs, **kwargs): 107 sitemap = kwargs.get("sitemap") 108 extras = kwargs.get("extras") # [extra_arg1,extra_arg2] 109 # some logic to filter-out fdata by fargs with taking into 110 # consideration extras ... 111 """ 112 blackout_list = filter(None, self.context.getBlackout_list()) 113 for frec in blackout_list: 114 fspec = frec.split(":") 115 fargs = fspec.pop() 116 fname = BLACKOUT_PREFIX + (fspec and fspec.pop() or "id") 117 futility = queryUtility(IBlackoutFilterUtility, name=fname) 118 if futility: 119 kw = {"sitemap": self.context, 120 "extras": fspec} 121 objects = futility.filterOut(objects, fargs, **kw) 122 return objects 84 123 85 124 def updateRequest(self):
Note: See TracChangeset
for help on using the changeset viewer.