Commit 863e9811 authored by Vincent Pelletier's avatar Vincent Pelletier

Factorize self.filter_dict[method_name] lookups.

Use an ImmutableSet instead of a dict where value = key.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19010 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 094862d8
...@@ -44,6 +44,7 @@ from xml.dom.minidom import parse ...@@ -44,6 +44,7 @@ from xml.dom.minidom import parse
from xml.sax.saxutils import escape, quoteattr from xml.sax.saxutils import escape, quoteattr
import os import os
import md5 import md5
from sets import ImmutableSet
try: try:
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
...@@ -1708,15 +1709,15 @@ class Catalog(Folder, ...@@ -1708,15 +1709,15 @@ class Catalog(Folder,
kw = {} kw = {}
if self.isMethodFiltered(method_name): if self.isMethodFiltered(method_name):
catalogged_object_list = [] catalogged_object_list = []
type_list = self.filter_dict[method_name]['type'] filter = self.filter_dict[method_name]
type_dict = dict(zip(type_list, type_list)) or None type_set = ImmutableSet(filter['type']) or None
expression = self.filter_dict[method_name]['expression_instance'] expression = filter['expression_instance']
expression_cache_key_list = self.filter_dict[method_name].get('expression_cache_key', '').split() expression_cache_key_list = filter.get('expression_cache_key', '').split()
for object in object_list: for object in object_list:
# We will check if there is an filter on this # We will check if there is an filter on this
# method, if so we may not call this zsqlMethod # method, if so we may not call this zsqlMethod
# for this object # for this object
if type_dict is not None and object.getPortalType() not in type_dict: if type_set is not None and object.getPortalType() not in type_set:
continue continue
elif expression is not None: elif expression is not None:
if expression_cache_key_list: if expression_cache_key_list:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment