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
Yusei Tahara
erp5
Commits
0c378e63
Commit
0c378e63
authored
Apr 18, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Use value instead of _value in BusinessItem objects
parent
f06117c3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
19 deletions
+20
-19
product/ERP5/Document/BusinessManager.py
product/ERP5/Document/BusinessManager.py
+17
-17
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+3
-2
No files found.
product/ERP5/Document/BusinessManager.py
View file @
0c378e63
...
...
@@ -543,8 +543,8 @@ class BusinessManager(XMLObject):
combined_added_path_item
=
reduce
(
lambda
x
,
y
:
x
+
y
,
path_item_list_add
)
combined_subtracted_path_item
=
reduce
(
lambda
x
,
y
:
x
+
y
,
path_item_list_subtract
)
added_value
=
combined_added_path_item
.
_
value
subtracted_value
=
combined_subtracted_path_item
.
_
value
added_value
=
combined_added_path_item
.
value
subtracted_value
=
combined_subtracted_path_item
.
value
if
added_value
!=
subtracted_value
:
# Append the arithmetically combined path_item objects in the final
...
...
@@ -552,8 +552,8 @@ class BusinessManager(XMLObject):
added_value
,
subtracted_value
=
\
self
.
_simplifyValueIntersection
(
added_value
,
subtracted_value
)
combined_added_path_item
.
_
value
=
added_value
combined_subtracted_path_item
.
_
value
=
subtracted_value
combined_added_path_item
.
value
=
added_value
combined_subtracted_path_item
.
value
=
subtracted_value
# Append the path_item to the final reduced path_item_list after
# doing required arithmetic on it. Make sure to first append
...
...
@@ -592,7 +592,7 @@ class BusinessManager(XMLObject):
return
added_value
,
subtracted_value
class
BusinessItem
(
Implicit
,
Persistent
):
class
BusinessItem
(
Persistent
):
"""Saves the path and values for objects, properties, etc, the
attributes for a path configuration being:
...
...
@@ -618,7 +618,7 @@ class BusinessItem(Implicit, Persistent):
self
.
_path
=
path
self
.
_sign
=
int
(
sign
)
self
.
_layer
=
int
(
layer
)
self
.
_
value
=
value
self
.
value
=
value
if
value
:
# Generate hash of from the value
self
.
_sha
=
self
.
_generateHash
()
...
...
@@ -631,20 +631,20 @@ class BusinessItem(Implicit, Persistent):
Initially, for simplicity, we go on with SHA256 values only
"""
LOG
(
'Business Manager'
,
INFO
,
'Genrating hash'
)
if
not
self
.
_
value
:
if
not
self
.
value
:
# Raise in case there is no value for the BusinessItem object
raise
ValueError
,
"Value not defined for the %s BusinessItem"
%
self
.
_path
elif
self
.
isProperty
:
# In case of property, the value is a PersisitentMapping object, so it
# can be easily hashed after formatting
sha256
=
hash
(
pprint
.
pformat
(
self
.
_
value
))
sha256
=
hash
(
pprint
.
pformat
(
self
.
value
))
else
:
# Expects to raise error on case the value for the object
# is not picklable
try
:
sha256
=
hashlib
.
sha256
(
self
.
_
value
).
hexdigest
()
sha256
=
hashlib
.
sha256
(
self
.
value
).
hexdigest
()
except
TypeError
:
obj_dict
=
self
.
_
value
.
__dict__
.
copy
()
obj_dict
=
self
.
value
.
__dict__
.
copy
()
del
obj_dict
[
'uid'
]
sha256
=
hash
(
pprint
.
pformat
(
obj_dict
))
self
.
_sha
=
sha256
...
...
@@ -673,7 +673,7 @@ class BusinessItem(Implicit, Persistent):
value
[
'name'
]
=
property_id
value
[
'type'
]
=
property_type
value
[
'value'
]
=
property_value
self
.
_
value
=
value
self
.
value
=
value
# Add the value object in the database
obj
.
_p_jar
.
add
(
value
)
# Generate hash for the property value
...
...
@@ -691,7 +691,7 @@ class BusinessItem(Implicit, Persistent):
obj
=
obj
.
_getCopy
(
context
)
obj
=
obj
.
__of__
(
context
)
_recursiveRemoveUid
(
obj
)
self
.
_
value
=
obj
self
.
value
=
obj
# Generate hash for the erp5 object value
self
.
_generateHash
()
except
AttributeError
:
...
...
@@ -776,7 +776,7 @@ class BusinessItem(Implicit, Persistent):
self
.
isProperty
=
True
relative_url
,
property_id
=
self
.
_path
.
split
(
'#'
)
obj
=
portal
.
unrestrictedTraverse
(
relative_url
)
prop
=
self
.
_
value
prop
=
self
.
value
# First remove the property from the existing path and keep the default
# empty, and update only if the sign is +1
obj
.
_delPropValue
(
prop
[
'name'
])
...
...
@@ -799,7 +799,7 @@ class BusinessItem(Implicit, Persistent):
# If sign is +1, set the new object on the container
if
self
.
_sign
==
1
:
# install object
obj
=
self
.
_
value
obj
=
self
.
value
obj
=
obj
.
_getCopy
(
container
)
container
.
_setObject
(
object_id
,
obj
)
obj
=
container
.
_getOb
(
object_id
)
...
...
@@ -867,7 +867,7 @@ class BusinessItem(Implicit, Persistent):
elif
self
.
_sign
!=
other
.
_sign
:
raise
ValueError
,
"BusinessItem are incommensurable, have different sign"
else
:
self
.
_value
=
self
.
_mergeValue
(
value_list
=
[
self
.
_value
,
other
.
_
value
])
self
.
value
=
self
.
_mergeValue
(
value_list
=
[
self
.
value
,
other
.
value
])
return
self
__radd__
=
__add__
...
...
@@ -1052,10 +1052,10 @@ class BusinessItem(Implicit, Persistent):
return
self
.
_layer
def
getBusinessPathValue
(
self
):
return
self
.
_
value
return
self
.
value
def
setBusinessPathValue
(
self
,
value
):
self
.
_
value
=
value
self
.
value
=
value
def
getBusinessPathSha
(
self
):
return
self
.
_sha
...
...
product/ERP5/Tool/TemplateTool.py
View file @
0c378e63
...
...
@@ -1747,7 +1747,8 @@ class TemplateTool (BaseTool):
# Update hashes of item in old state before installation
for
item
in
old_installation_state
.
_path_item_list
:
item
.
_sha
=
self
.
calculateComparableHash
(
item
.
_value
)
value
=
item
.
value
item
.
_sha
=
self
.
calculateComparableHash
(
value
)
# Path Item List for installation_process should be the difference between
# old and new installation state
...
...
@@ -1905,7 +1906,7 @@ class TemplateTool (BaseTool):
# XXX: Hack for not trying to install the sub-objects from zexp,
# This should rather be implemneted while exportign the object,
# where we shouldn't export sub-objects in the zexp
value
=
new_item
.
_
value
value
=
new_item
.
value
if
value
is
None
:
continue
if
value
.
_tree
:
...
...
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