Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alecs_myu
erp5
Commits
21d87cd4
Commit
21d87cd4
authored
Feb 13, 2018
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQLCatalog: Simplify and factorise _getCatalogMethodArgumentList
Document why this method tolerates unhandled method types.
parent
e1f60932
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
product/ERP5Catalog/Document/ERP5Catalog.py
product/ERP5Catalog/Document/ERP5Catalog.py
+10
-10
product/ZSQLCatalog/SQLCatalog.py
product/ZSQLCatalog/SQLCatalog.py
+13
-3
No files found.
product/ERP5Catalog/Document/ERP5Catalog.py
View file @
21d87cd4
...
...
@@ -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
)
...
...
product/ZSQLCatalog/SQLCatalog.py
View file @
21d87cd4
...
...
@@ -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
met
hod
.
meta_type
==
"Script (Python)"
:
elif
met
a_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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment