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
amrani
erp5
Commits
3b5f78ff
Commit
3b5f78ff
authored
Mar 29, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Resolve path for sub-objects in Business Manager path
parent
a51d7342
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
5 deletions
+50
-5
product/ERP5/Document/BusinessManager.py
product/ERP5/Document/BusinessManager.py
+50
-5
No files found.
product/ERP5/Document/BusinessManager.py
View file @
3b5f78ff
...
...
@@ -354,17 +354,56 @@ class BusinessManager(XMLObject):
"""
Store data for objects in the ERP5
"""
portal
=
self
.
getPortalObject
()
LOG
(
'Business Manager'
,
INFO
,
'Storing Manager Data'
)
self
.
_path_item_list
=
[]
path_item_list
=
self
.
getTemplatePathList
()
if
path_item_list
:
path_item_list
=
[
l
.
split
(
' | '
)
for
l
in
path_item_list
]
for
path_item
in
path_item_list
:
# Here we check for the path which also add sub-objects, in that case,
# we create separate BusinessItem objects for each sub-object with
# same layer and sign
# XXX: Not very effective as it tries to get all the objects which makes
# it vey slow
path_list
=
self
.
_resolvePath
(
portal
,
[],
path_item
[
0
].
split
(
'/'
))
for
path
in
path_list
:
try
:
self
.
_path_item_list
.
append
(
BusinessItem
(
path_item
[
0
]
,
path_item
[
1
],
path_item
[
2
]))
self
.
_path_item_list
.
append
(
BusinessItem
(
path
,
path_item
[
1
],
path_item
[
2
]))
except
IndexError
:
pass
def
_resolvePath
(
self
,
folder
,
relative_url_list
,
id_list
):
"""
For Business Manager, we expect to resolve the path incase we face
paths which expect to include sub-objects.
For example: 'portal_catalog/erp5_mysql_innodb/**' should only consider
the sub-objects of the object mentioned, and create separate BusinessItem
objects for all of them.
This method calls itself recursively.
The folder is the current object which contains sub-objects.
The list of ids are path components. If the list is empty,
the current folder is valid.
"""
if
len
(
id_list
)
==
0
:
return
[
'/'
.
join
(
relative_url_list
)]
id
=
id_list
[
0
]
if
re
.
search
(
'[
\
*
\
?
\
[
\
]]'
,
id
)
is
None
:
# If the id has no meta character, do not have to check all objects.
obj
=
folder
.
_getOb
(
id
,
None
)
if
obj
is
None
:
raise
AttributeError
,
"Could not resolve '%s' during business template processing."
%
id
return
self
.
_resolvePath
(
obj
,
relative_url_list
+
[
id
],
id_list
[
1
:])
path_list
=
[]
for
object_id
in
fnmatch
.
filter
(
folder
.
objectIds
(),
id
):
if
object_id
!=
""
:
path_list
.
extend
(
self
.
_resolvePath
(
folder
.
_getOb
(
object_id
),
relative_url_list
+
[
object_id
],
id_list
[
1
:]))
return
path_list
def
getPathList
(
self
):
path_list
=
[]
for
item
in
self
.
_path_item_list
:
...
...
@@ -656,6 +695,12 @@ class BusinessItem(Implicit, Persistent):
self
.
_generateHash
()
else
:
try
:
# XXX: After we apply _resolve path list while storing Data for the
# Business Manager, this should be of no use as there will be no path
# where we are going to achieve something different for relative_path
# from the result of _resolvePath on a given path.
# TODO: Remove this after checking successfull implementation of
# _resolve path in Business Manager in storeTemplateData
for
relative_url
in
self
.
_resolvePath
(
p
,
[],
path
.
split
(
'/'
)):
obj
=
p
.
unrestrictedTraverse
(
relative_url
)
obj
=
obj
.
_getCopy
(
context
)
...
...
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