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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mukul
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
Show 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
]
...
@@ -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,10 +696,11 @@ class BusinessItem(Implicit, Persistent):
...
@@ -687,10 +696,11 @@ 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
)
if
self
.
_sign
==
1
:
# install object
# install object
obj
=
self
.
_value
obj
=
self
.
_value
obj
=
obj
.
_getCopy
(
container
)
obj
=
obj
.
_getCopy
(
container
)
container
.
_setObject
(
object_id
,
obj
)
container
.
_setOb
(
object_id
,
obj
)
obj
=
container
.
_getOb
(
object_id
)
obj
=
container
.
_getOb
(
object_id
)
obj
.
isIndexable
=
ConstantGetter
(
'isIndexable'
,
value
=
False
)
obj
.
isIndexable
=
ConstantGetter
(
'isIndexable'
,
value
=
False
)
aq_base
(
obj
).
uid
=
portal
.
portal_catalog
.
newUid
()
aq_base
(
obj
).
uid
=
portal
.
portal_catalog
.
newUid
()
...
...
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