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
|
Rev | Line | |
---|
[2909] | 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.""" |
---|
[2912] | 11 | return [b for b in fdata if (b.getId or b.id) != fkey] |
---|
[2909] | 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.""" |
---|
[2920] | 21 | if fkey.startswith("/"): |
---|
[2922] | 22 | # absolute path filter |
---|
[2920] | 23 | return [b for b in fdata if b.getPath() != fkey] |
---|
| 24 | elif fkey.startswith("./"): |
---|
[2922] | 25 | # relative path filter |
---|
[2920] | 26 | smpath = kwargs.get("sitemap") |
---|
[2922] | 27 | contpath = '/'.join(smpath.getPhysicalPath()[:-1]) |
---|
[2920] | 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.