[Erp5-report] r10034 - /erp5/trunk/products/CMFCategory/Filter.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Sun Sep 17 14:01:31 CEST 2006
Author: jp
Date: Sun Sep 17 14:01:30 2006
New Revision: 10034
URL: http://svn.erp5.org?rev=10034&view=rev
Log:
Added support for arbitrary filtering
Modified:
erp5/trunk/products/CMFCategory/Filter.py
Modified: erp5/trunk/products/CMFCategory/Filter.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFCategory/Filter.py?rev=10034&r1=10033&r2=10034&view=diff
==============================================================================
--- erp5/trunk/products/CMFCategory/Filter.py (original)
+++ erp5/trunk/products/CMFCategory/Filter.py Sun Sep 17 14:01:30 2006
@@ -33,9 +33,14 @@
class Filter(Implicit):
- def __init__(self, spec=None, filter=None, portal_type=None):
+ def __init__(self, spec=None, filter=None, portal_type=None, filter_method=None):
"""
Initialize attributes. spec and portal_type can be lists, tuples or strings.
+
+ filter_method - filter_method allows for extending filtering in an arbitrary way
+ filter_method must be provided with a category and should
+ return 0 (False) or 1 (True)
+
"""
#LOG('Filter __init__', 0, 'self = %s, spec = %s, filter = %s, portal_type = %s' % (str(self), str(spec), str(filter), str(portal_type)))
if type(filter) is type({}):
@@ -54,6 +59,7 @@
# XXX An empty list or tuple is the same as None here.
if len(spec) > 0:
self.filter_dict['meta_type'] = spec
+ self.filter_method = filter_method
def test(self, context):
"""
@@ -67,6 +73,8 @@
return 0
elif context.getProperty(k) != v:
return 0
+ if self.filter_method is not None:
+ return self.filter_method(context)
return 1
More information about the Erp5-report
mailing list