Commit 21d87cd4 authored by Vincent Pelletier's avatar Vincent Pelletier

SQLCatalog: Simplify and factorise _getCatalogMethodArgumentList

Document why this method tolerates unhandled method types.
parent e1f60932
......@@ -178,6 +178,16 @@ class ERP5Catalog(Folder, Catalog):
isIndexable = 0
__class_init__ = Catalog.__class_init__
# Note: superclass supports older variants of these metatypes, but we do not
# expect these as content here. So just override superclass properties with
# the new metatypes.
HAS_ARGUMENT_SRC_METATYPE_SET = (
"ERP5 SQL Method",
)
HAS_FUNC_CODE_METATYPE_SET = (
"ERP5 Python Script",
)
def __init__(self, id, title='', container=None):
# Initialize both SQLCatalog as well as Folder
Catalog.__init__(self, id, title, container)
......@@ -325,16 +335,6 @@ class ERP5Catalog(Folder, Catalog):
def _getFilterDict(self):
return FilterDict(self)
def _getCatalogMethodArgumentList(self, method):
if method.meta_type == "LDIF Method":
# Build the dictionnary of values
return method.arguments_src.split()
elif method.meta_type == "ERP5 SQL Method":
return method.getArgumentsSrc().split()
elif method.meta_type == "ERP5 Python Script":
return method.func_code.co_varnames[:method.func_code.co_argcount]
return ()
def _getCatalogMethod(self, method_name):
return self._getOb(method_name)
......
......@@ -632,6 +632,13 @@ class Catalog(Folder,
manage_catalogAdvanced = DTMLFile('dtml/catalogAdvanced', globals())
_cache_sequence_number = 0
HAS_ARGUMENT_SRC_METATYPE_SET = (
"Z SQL Method",
"LDIF Method",
)
HAS_FUNC_CODE_METATYPE_SET = (
"Script (Python)",
)
def __init__(self, id, title='', container=None):
if container is not None:
......@@ -1479,11 +1486,14 @@ class Catalog(Folder,
raise
def _getCatalogMethodArgumentList(self, method):
if method.meta_type in ("Z SQL Method", "LDIF Method"):
# Build the dictionnary of values
meta_type = method.meta_type
if meta_type in self.HAS_ARGUMENT_SRC_METATYPE_SET:
return method.arguments_src.split()
elif method.meta_type == "Script (Python)":
elif meta_type in self.HAS_FUNC_CODE_METATYPE_SET:
return method.func_code.co_varnames[:method.func_code.co_argcount]
# Note: Raising here would completely prevent indexation from working.
# Instead, let the method actually fail when called, so _catalogObjectList
# can log the error and carry on.
return ()
def _getCatalogMethod(self, method_name):
......
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