Last change
on this file since 2922 was
2922,
checked in by mylan, 14 years ago
|
#228: Fix relative path filter tests and utility
|
-
Property svn:eol-style set to
native
|
File size:
1.0 KB
|
Line | |
---|
1 | from zope.interface import implements |
---|
2 | from quintagroup.plonegooglesitemaps.interfaces import IBlackoutFilterUtility |
---|
3 | |
---|
4 | class IdBlackoutFilterUtility(object): |
---|
5 | """Filter-out by ID utility.""" |
---|
6 | |
---|
7 | implements(IBlackoutFilterUtility) |
---|
8 | |
---|
9 | def filterOut(self, fdata, fkey, **kwargs): |
---|
10 | """Filter-out fdata list by id in fkey.""" |
---|
11 | return [b for b in fdata if (b.getId or b.id) != fkey] |
---|
12 | |
---|
13 | |
---|
14 | class PathBlackoutFilterUtility(object): |
---|
15 | """Filter-out by PATH utility.""" |
---|
16 | |
---|
17 | implements(IBlackoutFilterUtility) |
---|
18 | |
---|
19 | def filterOut(self, fdata, fkey, **kwargs): |
---|
20 | """Filter-out fdata list by path in fkey.""" |
---|
21 | if fkey.startswith("/"): |
---|
22 | # absolute path filter |
---|
23 | return [b for b in fdata if b.getPath() != fkey] |
---|
24 | elif fkey.startswith("./"): |
---|
25 | # relative path filter |
---|
26 | smpath = kwargs.get("sitemap") |
---|
27 | contpath = '/'.join(smpath.getPhysicalPath()[:-1]) |
---|
28 | resfilter = contpath + fkey[1:] |
---|
29 | return [b for b in fdata if b.getPath() != resfilter] |
---|
30 | return fdata |
---|
Note: See
TracBrowser
for help on using the repository browser.