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
Alain Takoudjou
erp5
Commits
b6e0d3b5
Commit
b6e0d3b5
authored
Mar 06, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Update install function for Business Item
parent
1551436f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
33 deletions
+43
-33
product/ERP5/Document/BusinessManager.py
product/ERP5/Document/BusinessManager.py
+43
-33
No files found.
product/ERP5/Document/BusinessManager.py
View file @
b6e0d3b5
...
@@ -376,15 +376,15 @@ class BusinessManager(XMLObject):
...
@@ -376,15 +376,15 @@ class BusinessManager(XMLObject):
"""
"""
if
self
.
status
==
'uninstalled'
:
if
self
.
status
==
'uninstalled'
:
self
.
reduceBusinessManager
()
self
.
reduceBusinessManager
()
elif
self
.
status
==
'reduced'
:
#
elif self.status == 'reduced':
self
.
flattenBusinessManager
()
#
self.flattenBusinessManager()
self
.
_install
()
self
.
_install
()
def
_install
(
self
):
def
_install
(
self
):
"""
"""
Run installation
Run installation
"""
"""
if
self
.
status
!=
'
flatten
ed'
:
if
self
.
status
!=
'
reduc
ed'
:
self
.
install
()
self
.
install
()
else
:
else
:
# Invoke install on every BusinessItem object
# Invoke install on every BusinessItem object
...
@@ -434,8 +434,8 @@ class BusinessManager(XMLObject):
...
@@ -434,8 +434,8 @@ class BusinessManager(XMLObject):
A Business Manager BT is said to be reduced if and only if:
A Business Manager BT is said to be reduced if and only if:
reduce(BT) = BT
reduce(BT) = BT
"""
"""
path_list
=
[
path_item
.
getBusinessPath
()
for
path_item
path_list
=
list
(
set
(
[
path_item
.
getBusinessPath
()
for
path_item
in
self
.
_path_item_list
]
in
self
.
_path_item_list
]
))
reduced_path_item_list
=
[]
reduced_path_item_list
=
[]
...
@@ -463,10 +463,10 @@ class BusinessManager(XMLObject):
...
@@ -463,10 +463,10 @@ class BusinessManager(XMLObject):
for
path
,
path_item_list
in
seen_path_dict
.
items
():
for
path
,
path_item_list
in
seen_path_dict
.
items
():
# Create separate list of list items with highest priority
# Create separate list of list items with highest priority
higest_priority_layer
=
max
(
path_item_list
,
key
=
attrgetter
(
'_layer'
))
higest_priority_layer
=
max
(
path_item_list
,
key
=
attrgetter
(
'_layer'
))
.
_layer
prioritized_path_item
=
[
path_item
for
path_item
prioritized_path_item
=
[
path_item
for
path_item
in
path_item_list
in
path_item_list
if
path_item
.
_layer
==
higest_priority_layer
.
_layer
]
if
path_item
.
_layer
==
higest_priority_layer
]
# Separate the positive and negative sign path_item
# Separate the positive and negative sign path_item
if
len
(
prioritized_path_item
)
>
1
:
if
len
(
prioritized_path_item
)
>
1
:
...
@@ -483,7 +483,7 @@ class BusinessManager(XMLObject):
...
@@ -483,7 +483,7 @@ class BusinessManager(XMLObject):
combined_subtracted_path_item
=
reduce
(
lambda
x
,
y
:
x
+
y
,
path_item_list_subtract
)
combined_subtracted_path_item
=
reduce
(
lambda
x
,
y
:
x
+
y
,
path_item_list_subtract
)
added_value
=
combined_added_path_item
.
_value
added_value
=
combined_added_path_item
.
_value
subtraced_value
=
combined_subtracted_path_item
.
_value
subtrac
t
ed_value
=
combined_subtracted_path_item
.
_value
if
added_value
!=
subtracted_value
:
if
added_value
!=
subtracted_value
:
# Append the arithmetically combined path_item objects in the final
# Append the arithmetically combined path_item objects in the final
...
@@ -495,9 +495,11 @@ class BusinessManager(XMLObject):
...
@@ -495,9 +495,11 @@ class BusinessManager(XMLObject):
combined_subtracted_path_item
.
_value
=
subtracted_value
combined_subtracted_path_item
.
_value
=
subtracted_value
# Append the path_item to the final reduced path_item_list after
# Append the path_item to the final reduced path_item_list after
# doing required arithmetic on it
# doing required arithmetic on it. Make sure to first append
reduced_path_item_list
.
append
(
combined_added_path_item
)
# subtracted item because while installation, we need to first
# uninstall the old object and then install new object at same path
reduced_path_item_list
.
append
(
combined_subtracted_path_item
)
reduced_path_item_list
.
append
(
combined_subtracted_path_item
)
reduced_path_item_list
.
append
(
combined_added_path_item
)
else
:
else
:
reduced_path_item_list
.
append
(
prioritized_path_item
[
0
])
reduced_path_item_list
.
append
(
prioritized_path_item
[
0
])
...
@@ -516,6 +518,12 @@ class BusinessManager(XMLObject):
...
@@ -516,6 +518,12 @@ class BusinessManager(XMLObject):
"""
"""
built_in_number_type
=
(
int
,
long
,
float
,
complex
)
built_in_number_type
=
(
int
,
long
,
float
,
complex
)
built_in_container_type
=
(
tuple
,
list
,
dict
,
set
)
built_in_container_type
=
(
tuple
,
list
,
dict
,
set
)
built_in_type_list
=
built_in_number_type
+
built_in_container_type
# For ERP5 objects, we should return the added and subtracted values as it is
if
type
(
added_value
).
__name__
not
in
built_in_type_list
and
\
type
(
subtracted_value
).
__name__
not
in
built_in_type_list
:
return
added_value
,
subtracted_value
# For all the values of container type, we remove the intersection
# For all the values of container type, we remove the intersection
added_value
=
[
x
for
x
in
added_value
if
x
not
in
subtracted_value
]
added_value
=
[
x
for
x
in
added_value
if
x
not
in
subtracted_value
]
...
@@ -609,23 +617,23 @@ class BusinessItem(Implicit, Persistent):
...
@@ -609,23 +617,23 @@ class BusinessItem(Implicit, Persistent):
def
_resolvePath
(
self
,
folder
,
relative_url_list
,
id_list
):
def
_resolvePath
(
self
,
folder
,
relative_url_list
,
id_list
):
"""
"""
We go through 3 types of paths:
We go through 3 types of paths:
1. General path we find in erp5 for objects
1. General path we find in erp5 for objects
Ex: portal_type/Person
Ex: portal_type/Person
In this case, we import/export the object on the path
In this case, we import/export the object on the path
2. Path where we consider saving sub-objects also, in that case we create
2. Path where we consider saving sub-objects also, in that case we create
new BusinessItem for those objects
new BusinessItem for those objects
Ex: portal_catalog/erp5_mysql_innodb/**
Ex: portal_catalog/erp5_mysql_innodb/**
This should create BI for the catalog methods sub-objects present in the
This should create BI for the catalog methods sub-objects present in the
erp5_catalog.
erp5_catalog.
This method calls itself recursively.
This method calls itself recursively.
The folder is the current object which contains sub-objects.
The folder is the current object which contains sub-objects.
The list of ids are path components. If the list is empty,
The list of ids are path components. If the list is empty,
the current folder is valid.
the current folder is valid.
"""
"""
if
len
(
id_list
)
==
0
:
if
len
(
id_list
)
==
0
:
return
[
'/'
.
join
(
relative_url_list
)]
return
[
'/'
.
join
(
relative_url_list
)]
...
@@ -669,6 +677,7 @@ class BusinessItem(Implicit, Persistent):
...
@@ -669,6 +677,7 @@ class BusinessItem(Implicit, Persistent):
"""
"""
# In case the path denotes property, we create separate object for
# In case the path denotes property, we create separate object for
# ObjectTemplateItem and handle the installation there.
# ObjectTemplateItem and handle the installation there.
import
pdb
;
pdb
.
set_trace
()
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
if
self
.
isProperty
:
if
self
.
isProperty
:
realtive_url
,
property_id
=
self
.
_path
.
split
(
'#'
)
realtive_url
,
property_id
=
self
.
_path
.
split
(
'#'
)
...
@@ -687,16 +696,17 @@ class BusinessItem(Implicit, Persistent):
...
@@ -687,16 +696,17 @@ class BusinessItem(Implicit, Persistent):
# delete the old object before installing a new object
# delete the old object before installing a new object
if
old_obj
:
if
old_obj
:
container
.
_delOb
(
object_id
)
container
.
_delOb
(
object_id
)
# install object
if
self
.
_sign
==
1
:
obj
=
self
.
_value
# install object
obj
=
obj
.
_getCopy
(
container
)
obj
=
self
.
_value
container
.
_setObject
(
object_id
,
obj
)
obj
=
obj
.
_getCopy
(
container
)
obj
=
container
.
_getOb
(
object_id
)
container
.
_setOb
(
object_id
,
obj
)
obj
.
isIndexable
=
ConstantGetter
(
'isIndexable'
,
value
=
False
)
obj
=
container
.
_getOb
(
object_id
)
aq_base
(
obj
).
uid
=
portal
.
portal_catalog
.
newUid
()
obj
.
isIndexable
=
ConstantGetter
(
'isIndexable'
,
value
=
False
)
del
obj
.
isIndexable
aq_base
(
obj
).
uid
=
portal
.
portal_catalog
.
newUid
()
if
getattr
(
aq_base
(
obj
),
'reindexObject'
,
None
)
is
not
None
:
del
obj
.
isIndexable
obj
.
reindexObject
()
if
getattr
(
aq_base
(
obj
),
'reindexObject'
,
None
)
is
not
None
:
obj
.
reindexObject
()
def
unrestrictedResolveValue
(
self
,
context
=
None
,
path
=
''
,
default
=
_MARKER
,
def
unrestrictedResolveValue
(
self
,
context
=
None
,
path
=
''
,
default
=
_MARKER
,
restricted
=
0
):
restricted
=
0
):
...
...
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