Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
716344c6
Commit
716344c6
authored
Apr 26, 2017
by
Ayush Tiwari
Committed by
Ayush Tiwari
Nov 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Use property for BusinessManager object(s)
parent
14ad8ae5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
63 deletions
+20
-63
product/ERP5/Document/BusinessManager.py
product/ERP5/Document/BusinessManager.py
+20
-63
No files found.
product/ERP5/Document/BusinessManager.py
View file @
716344c6
...
@@ -153,7 +153,7 @@ class BusinessManager(Folder):
...
@@ -153,7 +153,7 @@ class BusinessManager(Folder):
"""
"""
_properties = (
_properties = (
{'id': '
template
_path_list',
{'id': '
manager
_path_list',
'type': 'lines',
'type': 'lines',
'default': 'python: ()',
'default': 'python: ()',
'acquisition_base_category': (),
'acquisition_base_category': (),
...
@@ -174,10 +174,8 @@ class BusinessManager(Folder):
...
@@ -174,10 +174,8 @@ class BusinessManager(Folder):
)
)
"""
"""
template_path_list
=
()
template_format_version
=
3
template_format_version
=
3
status
=
'uninstalled'
status
=
'uninstalled'
_path_item_list
=
PersistentList
()
# Declarative security
# Declarative security
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
@@ -216,26 +214,18 @@ class BusinessManager(Folder):
...
@@ -216,26 +214,18 @@ class BusinessManager(Folder):
portal
=
self
.
getPortalObject
()
portal
=
self
.
getPortalObject
()
pass
pass
def
edit
(
self
,
**
kw
):
def
edit
(
self
,
manager_path_list
=
[],
**
kw
):
"""
"""
Explicilty edit the class instance
Explicilty edit the class instance
XXX: No need of this class ? as we already have _edit from ERP5Type.Folder
XXX: No need of this class ? as we already have _edit from ERP5Type.Folder
"""
"""
if
'template_path_list'
in
kw
:
super
(
BusinessManager
,
self
).
edit
(
manager_path_list
=
manager_path_list
,
**
kw
)
path_item_list
=
kw
.
pop
(
'template_path_list'
)
self
.
_setTemplatePathList
(
path_item_list
)
def
_setTemplatePathList
(
self
,
path_item_list
):
self
.
template_path_list
=
path_item_list
def
getTemplatePathList
(
self
):
def
getTemplatePathList
(
self
):
return
self
.
template_path_list
return
self
.
getProperty
(
'manager_path_list'
)
def
getPathItemList
(
self
):
def
getPathItemList
(
self
):
try
:
return
self
.
objectValues
()
return
self
.
_path_item_list
except
AttributeError
:
return
[]
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'_getTemplatePathList'
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'_getTemplatePathList'
)
def
_getTemplatePathList
(
self
):
def
_getTemplatePathList
(
self
):
...
@@ -244,10 +234,12 @@ class BusinessManager(Folder):
...
@@ -244,10 +234,12 @@ class BusinessManager(Folder):
result
=
tuple
(
result
)
result
=
tuple
(
result
)
return
result
return
result
# XXX: Change into property
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'getTemplateFormatVersion'
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'getTemplateFormatVersion'
)
def
getTemplateFormatVersion
(
self
):
def
getTemplateFormatVersion
(
self
):
return
self
.
template_format_version
return
self
.
template_format_version
# XXX: Change into property
def
_setTemplateFormatVersion
(
self
,
value
):
def
_setTemplateFormatVersion
(
self
,
value
):
self
.
template_format_version
=
int
(
value
)
self
.
template_format_version
=
int
(
value
)
...
@@ -293,18 +285,19 @@ class BusinessManager(Folder):
...
@@ -293,18 +285,19 @@ class BusinessManager(Folder):
"""
"""
connection
=
self
.
aq_parent
.
_p_jar
connection
=
self
.
aq_parent
.
_p_jar
file
=
open
(
path
,
'rb'
)
file
=
open
(
path
,
'rb'
)
obj
=
connection
.
importFile
(
file
)
imported_manager
=
connection
.
importFile
(
file
)
self
.
title
=
obj
.
title
self
.
title
=
imported_manager
.
title
self
.
_path_item_list
=
obj
.
_path_item_list
[:]
for
obj
in
imported_manager
.
objectValues
():
self
.
_setTemplatePathList
(
obj
.
getTemplatePathList
())
self
.
_setObject
(
obj
.
getId
(),
obj
)
self
.
setProperty
(
'manager_path_list'
,
obj
.
getTemplatePathList
())
def
__add__
(
self
,
other
):
def
__add__
(
self
,
other
):
"""
"""
Adds the Business Item objects for the given Business Manager objects
Adds the Business Item objects for the given Business Manager objects
"""
"""
self
.
_path_item_list
.
extend
(
other
.
_path_item_list
)
self
.
_path_item_list
.
extend
(
other
.
_path_item_list
)
template_path_list
=
list
(
self
.
template_path_list
)
+
list
(
other
.
template
_path_list
)
manager_path_list
=
list
(
self
.
manager_path_list
)
+
list
(
other
.
manager
_path_list
)
self
.
template_path_list
=
template
_path_list
self
.
manager_path_list
=
manager
_path_list
return
self
return
self
__radd__
=
__add__
__radd__
=
__add__
...
@@ -342,9 +335,6 @@ class BusinessManager(Folder):
...
@@ -342,9 +335,6 @@ class BusinessManager(Folder):
exisiting_path_item_id_list
=
[
l
for
l
in
self
.
objectIds
()]
exisiting_path_item_id_list
=
[
l
for
l
in
self
.
objectIds
()]
self
.
manage_delObjects
(
ids
=
exisiting_path_item_id_list
)
self
.
manage_delObjects
(
ids
=
exisiting_path_item_id_list
)
# Create an empty _path_item_list everytime we storeTemplateData
self
.
_path_item_list
=
PersistentList
()
if
path_item_list
:
if
path_item_list
:
path_item_list
=
[
l
.
split
(
' | '
)
for
l
in
path_item_list
]
path_item_list
=
[
l
.
split
(
' | '
)
for
l
in
path_item_list
]
...
@@ -359,7 +349,6 @@ class BusinessManager(Folder):
...
@@ -359,7 +349,6 @@ class BusinessManager(Folder):
item_sign
=
path_item
[
1
],
item_sign
=
path_item
[
1
],
item_layer
=
path_item
[
2
]
item_layer
=
path_item
[
2
]
)
)
self
.
_path_item_list
.
append
(
PathItem
)
else
:
else
:
# Here we check for the path which also add sub-objects, in that case,
# Here we check for the path which also add sub-objects, in that case,
# we create separate BusinessItem objects for each sub-object with
# we create separate BusinessItem objects for each sub-object with
...
@@ -378,7 +367,6 @@ class BusinessManager(Folder):
...
@@ -378,7 +367,6 @@ class BusinessManager(Folder):
item_sign
=
path_item
[
1
],
item_sign
=
path_item
[
1
],
item_layer
=
path_item
[
2
]
item_layer
=
path_item
[
2
]
)
)
self
.
_path_item_list
.
append
(
PathItem
)
resolved_path
=
(
' | '
).
join
((
path
,
path_item
[
1
],
path_item
[
2
]))
resolved_path
=
(
' | '
).
join
((
path
,
path_item
[
1
],
path_item
[
2
]))
new_path_item_list
.
append
(
resolved_path
)
new_path_item_list
.
append
(
resolved_path
)
except
IndexError
:
except
IndexError
:
...
@@ -390,12 +378,10 @@ class BusinessManager(Folder):
...
@@ -390,12 +378,10 @@ class BusinessManager(Folder):
item_sign
=
path_item
[
1
],
item_sign
=
path_item
[
1
],
item_layer
=
path_item
[
2
]
item_layer
=
path_item
[
2
]
)
)
# If not build, i.e, import/export, just update the _path_item_list
self
.
_path_item_list
.
append
(
PathItem
)
if
isBuild
:
if
isBuild
:
# If build process, update the path list of the Business Manager
# If build process, update the path list of the Business Manager
self
.
_setTemplatePathList
(
new_path_item_list
)
self
.
setProperty
(
'manager_path_list'
,
new_path_item_list
)
def
_resolvePath
(
self
,
folder
,
relative_url_list
,
id_list
):
def
_resolvePath
(
self
,
folder
,
relative_url_list
,
id_list
):
"""
"""
...
@@ -430,15 +416,15 @@ class BusinessManager(Folder):
...
@@ -430,15 +416,15 @@ class BusinessManager(Folder):
def
getPathList
(
self
):
def
getPathList
(
self
):
path_list
=
[]
path_list
=
[]
for
item
in
self
.
_path_item_list
:
for
item
in
self
.
objectValues
()
:
path_list
.
append
(
item
.
path
)
path_list
.
append
(
item
.
getProperty
(
'path'
)
)
return
path_list
return
path_list
def
getPathShaDict
(
self
):
def
getPathShaDict
(
self
):
path_sha_dict
=
{}
path_sha_dict
=
{}
# TODO: Handle error for BM with multiple items at same path
# TODO: Handle error for BM with multiple items at same path
for
item
in
self
.
_path_item_list
:
for
item
in
self
.
objectValues
()
:
path_sha_dict
[
item
.
path
]
=
item
.
sha
path_sha_dict
[
item
.
getProperty
(
'path'
)]
=
item
.
getProperty
(
'sha'
)
return
path_item_dict
return
path_item_dict
def
getPathItemDict
(
self
):
def
getPathItemDict
(
self
):
...
@@ -461,40 +447,11 @@ class BusinessManager(Folder):
...
@@ -461,40 +447,11 @@ class BusinessManager(Folder):
LOG
(
'Business Manager'
,
INFO
,
'Building Business Manager'
)
LOG
(
'Business Manager'
,
INFO
,
'Building Business Manager'
)
if
not
no_action
:
if
not
no_action
:
self
.
storeTemplateData
(
isBuild
=
True
)
self
.
storeTemplateData
(
isBuild
=
True
)
for
path_item
in
self
.
_path_item_list
:
for
path_item
in
self
.
objectValues
()
:
path_item
.
build
(
self
,
**
kw
)
path_item
.
build
(
self
,
**
kw
)
self
.
status
=
'built'
self
.
status
=
'built'
return
self
return
self
def
install
(
self
):
"""
Installs the Business Manager in steps:
1. Reduction of the BT
2. Flattenning the BT
3. Copying the object at the path mentioned in BT
"""
if
self
.
status
==
'uninstalled'
:
self
.
reduceBusinessManager
()
#elif self.status == 'reduced':
# self.flattenBusinessManager()
self
.
_install
()
def
_install
(
self
):
"""
Run installation
"""
if
self
.
status
!=
'reduced'
:
self
.
install
()
else
:
# Invoke install on every BusinessItem object
for
path_item
in
self
.
_path_item_list
:
path_item
.
install
()
def
upgrade
(
self
):
"""Upgrade the Business Manager"""
pass
def
flattenBusinessManager
(
self
):
def
flattenBusinessManager
(
self
):
"""
"""
Flattening a reduced Business Manager with two path p1 and p2 where p1 <> p2:
Flattening a reduced Business Manager with two path p1 and p2 where p1 <> p2:
...
...
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