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
Léo-Paul Géneau
erp5
Commits
b64b44b1
Commit
b64b44b1
authored
Jan 15, 2024
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BusinessTemplate: improve parser for paths
parent
be443444
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
6 deletions
+40
-6
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBusinessTemplate.py
...eItem/portal_components/test.erp5.testBusinessTemplate.py
+3
-0
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+37
-6
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBusinessTemplate.py
View file @
b64b44b1
...
...
@@ -7602,6 +7602,9 @@ class TestBusinessTemplate(BusinessTemplateMixin):
business_template
.
setProperty
(
property_id
,
[
"aa/**"
])
self
.
assertEqual
(
True
,
method
(
"aa/bb"
))
self
.
assertEqual
(
True
,
method
(
"aa/bb/cc"
))
business_template
.
setProperty
(
property_id
,
[
"aa/b*/**"
])
self
.
assertEqual
(
False
,
method
(
"aa/bb"
))
self
.
assertEqual
(
True
,
method
(
"aa/bb/cc"
))
def
stepCreateDocumentComponentWhichTriggersAnOperationWhenSubDocumentIsAdded
(
self
,
sequence
=
None
,
**
kw
):
...
...
product/ERP5/Document/BusinessTemplate.py
View file @
b64b44b1
...
...
@@ -5674,14 +5674,45 @@ Business Template is a set of definitions, such as skins, portal types and categ
return
super
(
BusinessTemplate
,
self
).
_edit
(
*
args
,
**
edit_kw
)
def
_isInKeepList
(
self
,
keep_list
,
path
):
path_components
=
path
.
split
(
'/'
)
path_components_len
=
len
(
path_components
)
for
keep_path
in
keep_list
:
if
keep_path
.
endswith
(
'**'
)
and
path
.
startswith
(
keep_path
[:
-
2
]):
return
True
elif
keep_path
.
endswith
(
'*'
)
and
path
.
startswith
(
keep_path
[:
-
1
])
\
and
len
(
keep_path
.
split
(
'/'
))
==
len
(
path
.
split
(
'/'
)):
return
True
elif
path
==
keep_path
:
include_all_subobjects
=
False
if
keep_path
.
endswith
(
'**'
):
include_all_subobjects
=
True
keep_path
=
keep_path
[:
-
2
]
keep_path_components
=
keep_path
.
split
(
'/'
)
keep_path_components_len
=
len
(
keep_path_components
)
# Preliminary check: path should have the same number of components
# except when a wildcard is given
if
keep_path_components_len
!=
path_components_len
:
if
not
include_all_subobjects
:
continue
# In any case, matcher should not have more components than path
elif
keep_path_components_len
>
path_components_len
:
continue
path_equal
=
True
for
(
i
,
keep_path_component
)
in
enumerate
(
keep_path_components
):
# Should accept `test_abc` when component is `test_*` (component wildcard)
# but also `test_**` (global wildcard)
if
keep_path_component
.
endswith
(
'*'
)
or
(
include_all_subobjects
and
i
==
keep_path_components_len
-
1
):
if
not
path_components
[
i
].
startswith
(
keep_path_component
[:
-
1
]):
path_equal
=
False
break
else
:
# Strict equality check when no wildcard is given
if
path_components
[
i
]
!=
keep_path_component
:
path_equal
=
False
break
if
path_equal
:
return
True
return
False
security
.
declarePrivate
(
'isKeepObject'
)
...
...
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