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
Laurent S
erp5
Commits
a51d7342
Commit
a51d7342
authored
Mar 28, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Add property to be also considered as BusinessItem objects
parent
388e0bcf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
+23
-10
product/ERP5/Document/BusinessManager.py
product/ERP5/Document/BusinessManager.py
+23
-10
No files found.
product/ERP5/Document/BusinessManager.py
View file @
a51d7342
...
...
@@ -53,7 +53,7 @@ from Products.ERP5Type.XMLObject import XMLObject
from
Products.CMFCore.utils
import
getToolByName
from
Products.PythonScripts.PythonScript
import
PythonScript
from
Products.ERP5Type.dynamic.lazy_class
import
ERP5BaseBroken
from
Products.ERP5Type.Globals
import
Persistent
from
Products.ERP5Type.Globals
import
Persistent
,
PersistentMapping
from
Products.ERP5Type
import
Permissions
,
PropertySheet
,
interfaces
from
AccessControl
import
ClassSecurityInfo
,
Unauthorized
,
getSecurityManager
from
Acquisition
import
Implicit
,
aq_base
,
aq_inner
,
aq_parent
...
...
@@ -610,6 +610,10 @@ class BusinessItem(Implicit, Persistent):
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
))
else
:
# Expects to raise error on case the value for the object
# is not picklable
...
...
@@ -639,7 +643,15 @@ class BusinessItem(Implicit, Persistent):
relative_url
,
property_id
=
path
.
split
(
'#'
)
obj
=
p
.
unrestrictedTraverse
(
relative_url
)
property_value
=
obj
.
getProperty
(
property_id
)
self
.
_value
=
property_value
property_type
=
obj
.
getPropertyType
(
property_id
)
# Create a persistent object which can be saved inside ZODB for the value
value
=
PersistentMapping
()
value
[
'name'
]
=
property_id
value
[
'type'
]
=
property_type
value
[
'value'
]
=
property_value
self
.
_value
=
value
# Add the value object in the database
obj
.
_p_jar
.
add
(
value
)
# Generate hash for the property value
self
.
_generateHash
()
else
:
...
...
@@ -730,10 +742,14 @@ class BusinessItem(Implicit, Persistent):
# In case the path denotes property, we create separate object for
# ObjectTemplateItem and handle the installation there.
portal
=
context
.
getPortalObject
()
if
self
.
isProperty
:
realtive_url
,
property_id
=
self
.
_path
.
split
(
'#'
)
object_property_item
=
ObjectPropertyTemplateItem
(
id_list
)
object_property_item
.
install
()
if
'#'
in
str
(
self
.
_path
):
self
.
isProperty
=
True
relative_url
,
property_id
=
self
.
_path
.
split
(
'#'
)
obj
=
portal
.
unrestrictedTraverse
(
relative_url
)
# XXX: Here, we do deal with different cases such as if the object exists
# or not or have the same value or compare states
prop
=
self
.
_value
obj
.
setProperty
(
prop
[
'name'
],
prop
[
'value'
],
prop
[
'type'
])
else
:
path_list
=
self
.
_path
.
split
(
'/'
)
container_path
=
path_list
[:
-
1
]
...
...
@@ -1004,7 +1020,6 @@ class BusinessItem(Implicit, Persistent):
# We now will add the XML object and its sha hash while exporting the object
# to Business Manager itself
# Back compatibility with filesystem Documents
key
=
self
.
_path
obj
=
self
.
_value
...
...
@@ -1340,5 +1355,3 @@ class bm(dict):
def
_importFile
(
self
,
file_name
,
file
,
parent
):
self
[
file_name
]
=
file
.
read
()
#InitializeClass(BusinessManager)
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