Changeset 2941 in products for quintagroup.plonegooglesitemaps/branches/blacklist
- Timestamp:
- Oct 28, 2010 6:10:51 PM (14 years ago)
- Location:
- quintagroup.plonegooglesitemaps/branches/blacklist/quintagroup/plonegooglesitemaps
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonegooglesitemaps/branches/blacklist/quintagroup/plonegooglesitemaps/browser/commonview.py
r2940 r2941 84 84 """Return blkack-out filtered objects 85 85 Every record in blackout_list filter should follow the spec: 86 [extra filter data, separated by ':':][<filter name>:]<filter data>86 [<filter name>:]<filter arguments> 87 87 For example: 88 88 1| index.html … … 90 90 3| path:/folder_1_level/obj_in_folder 91 91 4| path:./folder_near_sitemap/obj_in_folder 92 5| extra_arg1:extra_arg2:super_filter:super arg-1, superarg-292 5| foo_filter:arg-1, arg-2 93 93 94 94 1->used default "id" filter - remove "index.html" objects; … … 97 97 path from the root of the plone site; 98 98 4->same to 3), but path get from the folder, where sitemap is located; 99 5->filter name is "super_filter" (must be registered IBlackoutFilterUtility, 100 named "seoptimzier.blackoutfilter.super_filter:), which get list of extra 101 parameters, e.g. [extra_arg1,extra_arg2] to the filterOut method in 102 "extras" option, and get filter arguments: super arg-1, super arg-2 99 5->filter name is "foo_filter" (must be registered IBlackoutFilter, 100 named "foo_filter"), which get filter arguments: arg-1, arg-2 103 101 104 class SuperFilterUtility(object): 105 def filterOut(self, fdata, fargs, **kwargs): 106 sitemap = kwargs.get("sitemap") 107 extras = kwargs.get("extras") # [extra_arg1,extra_arg2] 102 class FooFilterUtility(object): 103 def __init__(self, context, request): 104 self.context = context 105 self.request = request 106 def filterOut(self, fdata, fargs): 108 107 # some logic to filter-out fdata by fargs with taking into 109 # consideration extras ...108 # consideration self.context and self.request, if needed. 110 109 """ 111 110 blackout_list = filter(None, self.context.getBlackout_list()) 112 111 for frec in blackout_list: 113 fspec = frec.split(":" )112 fspec = frec.split(":", 1) 114 113 fargs = fspec.pop() 115 114 fname = fspec and fspec.pop() or "id" -
quintagroup.plonegooglesitemaps/branches/blacklist/quintagroup/plonegooglesitemaps/tests/testBlackoutList.py
r2940 r2941 4 4 from base import * 5 5 from types import ListType, TupleType 6 from zope import component 6 7 from zope.component import queryMultiAdapter 7 8 … … 89 90 90 91 91 92 92 class TestBlacklistFormProcessing(TestFilterMixin): 93 93 … … 125 125 'id-named: %s\nunnamed: %s' % (filtered, filtered_dflt)) 126 126 127 # def testGetCorrectFilterName(self): 128 # call_names = [] 129 # origQMA = component._api.queryMultiAdapter 130 # def patchQMA(objects, interface=Interface, name=u'', context=None): 131 # call_names.append(name) 132 # origQMA(objects, interface=interface, name=name, context=context) 133 # component.queryMutliAdapter = patchQMA 134 # self.sm.edit(blackout_list="FooFilterName:arg1:arg2:doc1") 135 # self.smview.results() 136 # self.assertTrue("FooFilterName" in call_names, 137 # "Wrong filter name parsing - no FooFilterName in %s" % call_names) 138 # component._api.queryMutliAdapter = origQMA 139 140 141 127 142 128 143 def test_suite():
Note: See TracChangeset
for help on using the changeset viewer.