Commit 0ffaf172 authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Refactor _catalogObject List to remove the need to copy and patch

Create FilterDict and Filter class which would be used to imitate the behaviour
of filter_dict for Catalog.
parent 99230fae
This diff is collapsed.
...@@ -737,10 +737,11 @@ class Catalog(Folder, ...@@ -737,10 +737,11 @@ class Catalog(Folder,
f.write(' </property>\n') f.write(' </property>\n')
# XXX Although filters are not properties, output filters here. # XXX Although filters are not properties, output filters here.
# XXX Ideally, filters should be properties in Z SQL Methods, shouldn't they? # XXX Ideally, filters should be properties in Z SQL Methods, shouldn't they?
if hasattr(self, 'filter_dict'): filter_dict = self._getFilterDict()
if filter_dict:
filter_list = [] filter_list = []
for filter_id in self.filter_dict.keys(): for filter_id in filter_dict.keys():
filter_definition = self.filter_dict[filter_id] filter_definition = filter_dict[filter_id]
filter_list.append((filter_id, filter_definition)) filter_list.append((filter_id, filter_definition))
# Sort for easy diff # Sort for easy diff
filter_list.sort(key=lambda x: x[0]) filter_list.sort(key=lambda x: x[0])
...@@ -1601,7 +1602,7 @@ class Catalog(Folder, ...@@ -1601,7 +1602,7 @@ class Catalog(Folder,
with (noReadOnlyTransactionCache if disable_cache else with (noReadOnlyTransactionCache if disable_cache else
readOnlyTransactionCache)(): readOnlyTransactionCache)():
filter_dict = self.filter_dict filter_dict = self._getFilterDict()
catalogged_object_list_cache = {} catalogged_object_list_cache = {}
for method_name in method_id_list: for method_name in method_id_list:
# We will check if there is an filter on this # We will check if there is an filter on this
...@@ -1697,7 +1698,10 @@ class Catalog(Folder, ...@@ -1697,7 +1698,10 @@ class Catalog(Folder,
if psyco is not None: if psyco is not None:
psyco.bind(_catalogObjectList) psyco.bind(_catalogObjectList)
def _getCatalogMethodArgumentList(self, method): def _getFilterDict(self):
return self.filter_dict
def _getCatalogMethodArgumentList(self, method_name):
if method.meta_type in ("Z SQL Method", "LDIF Method"): if method.meta_type in ("Z SQL Method", "LDIF Method"):
# Build the dictionnary of values # Build the dictionnary of values
return method.arguments_src.split() return method.arguments_src.split()
......
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