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
5de3b2af
Commit
5de3b2af
authored
Jan 30, 2017
by
Ayush Tiwari
Committed by
Ayush Tiwari
Nov 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5-prototype: Save type in xml for Object property objects in BP
parent
1e09f68d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
20 deletions
+34
-20
product/ERP5/Document/BusinessPackage.py
product/ERP5/Document/BusinessPackage.py
+34
-20
No files found.
product/ERP5/Document/BusinessPackage.py
View file @
5de3b2af
...
@@ -162,10 +162,7 @@ class BusinessPackage(XMLObject):
...
@@ -162,10 +162,7 @@ class BusinessPackage(XMLObject):
self
.
storePathData
()
self
.
storePathData
()
# XXX: Explicitly calling build for items. Needs to be changed
# XXX: Explicitly calling build for items. Needs to be changed
self
.
_path_item
.
build
(
self
,
**
kw
)
self
.
_path_item
.
build
(
self
,
**
kw
)
try
:
self
.
_object_property_item
.
build
(
self
)
self
.
_object_property_item
.
build
(
self
)
except
Exception
:
import
pdb
;
pdb
.
set_trace
()
pass
pass
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'storePathData'
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'storePathData'
)
...
@@ -928,24 +925,30 @@ class ObjectPropertyTemplatePackageItem(Implicit, Persistent):
...
@@ -928,24 +925,30 @@ class ObjectPropertyTemplatePackageItem(Implicit, Persistent):
p
=
context
.
getPortalObject
()
p
=
context
.
getPortalObject
()
for
key
in
self
.
_archive
:
for
key
in
self
.
_archive
:
relative_url
,
property_name
=
key
.
split
(
' | '
)
relative_url
,
property_name
=
key
.
split
(
' | '
)
property_value
=
p
.
unrestrictedTraverse
(
relative_url
)
\
obj
=
p
.
unrestrictedTraverse
(
relative_url
)
.
getProperty
(
property_name
)
property_value
=
obj
.
getProperty
(
property_name
)
self
.
_objects
.
setdefault
(
relative_url
,
{})[
property_name
]
=
property_value
property_type
=
obj
.
getPropertyType
(
property_name
)
# XXX: Add property_type in the xml generated for the objects
property_dict
=
{
self
.
_hash
[
relative_url
]
=
hashlib
.
sha1
(
self
.
generateXml
(
relative_url
)).
hexdigest
()
'id'
:
property_name
,
'value'
:
property_value
,
'type'
:
property_type
,
}
self
.
_objects
.
setdefault
(
relative_url
,
[]).
append
(
property_dict
)
def
generateXml
(
self
,
path
):
def
generateXml
(
self
,
path
):
xml_data
=
'<%s>'
%
self
.
xml_tag
xml_data
=
'<%s>'
%
self
.
xml_tag
relative_url
=
path
relative_url
=
path
xml_data
+=
'
\
n
<object relative_url="%s">'
%
relative_url
xml_data
+=
'
\
n
<object relative_url="%s">'
%
relative_url
for
property_
name
,
property_value
in
self
.
_objects
[
relative_url
].
iteritems
()
:
for
property_
dict
in
self
.
_objects
[
relative_url
]
:
# XXX: Replacing '_list' is not very safely handled for exceptional cases
# XXX: Replacing '_list' is not very safely handled for exceptional cases
xml_data
+=
'
\
n
<property name="%s">'
%
property_name
.
replace
(
'_list'
,
''
)
xml_data
+=
'
\
n
<property>'
if
property_name
.
endswith
(
'_list'
):
xml_data
+=
'
\
n
<name>%s</name>'
%
property_dict
[
'id'
].
replace
(
'_list'
,
''
)
for
value
in
property_value
:
xml_data
+=
'
\
n
<type>%s</type>'
%
property_dict
[
'type'
]
if
property_dict
[
'id'
].
endswith
(
'_list'
):
for
value
in
property_dict
[
'value'
]:
xml_data
+=
'
\
n
<item>%s</item>'
%
value
xml_data
+=
'
\
n
<item>%s</item>'
%
value
else
:
else
:
xml_data
+=
'
\
n
<item>%s</item>'
%
property_
value
xml_data
+=
'
\
n
<item>%s</item>'
%
property_
dict
[
'value'
]
xml_data
+=
'
\
n
</property>'
xml_data
+=
'
\
n
</property>'
xml_data
+=
'
\
n
</object>'
xml_data
+=
'
\
n
</object>'
xml_data
+=
'
\
n
</%s>'
%
self
.
xml_tag
xml_data
+=
'
\
n
</%s>'
%
self
.
xml_tag
...
@@ -973,8 +976,19 @@ class ObjectPropertyTemplatePackageItem(Implicit, Persistent):
...
@@ -973,8 +976,19 @@ class ObjectPropertyTemplatePackageItem(Implicit, Persistent):
item_list
=
[]
item_list
=
[]
for
item
in
obj_property
.
findall
(
'item'
):
for
item
in
obj_property
.
findall
(
'item'
):
item_list
.
append
(
item
.
text
)
item_list
.
append
(
item
.
text
)
property_name
=
obj_property
.
get
(
'name'
)
+
(
''
if
len
(
item_list
)
<=
1
else
'_list'
)
property_name
=
obj_property
.
find
(
'name'
).
text
+
(
''
if
len
(
item_list
)
<=
1
else
'_list'
)
self
.
_objects
[
obj
.
get
(
'relative_url'
)]
=
{
property_name
:
item_list
}
property_type
=
obj_property
.
find
(
'type'
).
text
if
property_type
not
in
(
'lines'
,
'selection'
,
'multiple selection'
):
try
:
item_list
=
item_list
[
0
]
except
IndexError
:
item_list
=
''
property_dict
=
{
'id'
:
property_name
,
'value'
:
item_list
,
'type'
:
property_type
,
}
self
.
_objects
.
setdefault
(
obj
.
get
(
'relative_url'
),
[]).
append
(
property_dict
)
def
preinstall
(
self
,
context
,
installed_item
,
**
kw
):
def
preinstall
(
self
,
context
,
installed_item
,
**
kw
):
modified_object_list
=
{}
modified_object_list
=
{}
...
@@ -992,15 +1006,15 @@ class ObjectPropertyTemplatePackageItem(Implicit, Persistent):
...
@@ -992,15 +1006,15 @@ class ObjectPropertyTemplatePackageItem(Implicit, Persistent):
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
for
relative_url
in
self
.
_objects
:
for
relative_url
in
self
.
_objects
:
obj
=
portal
.
unrestrictedTraverse
(
relative_url
)
obj
=
portal
.
unrestrictedTraverse
(
relative_url
)
for
property_
name
,
property_value
in
self
.
_objects
[
relative_url
].
iteritems
()
:
for
property_
dict
in
self
.
_objects
[
relative_url
]
:
obj
.
setProperty
(
property_
name
,
property_value
)
obj
.
setProperty
(
property_
dict
[
'id'
],
property_dict
[
'value'
],
property_dict
[
'type'
]
)
def
uninstall
(
self
,
context
,
**
kw
):
def
uninstall
(
self
,
context
,
**
kw
):
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
for
relative_url
in
self
.
_objects
:
for
relative_url
in
self
.
_objects
:
obj
=
portal
.
unrestrictedTraverse
(
relative_url
)
obj
=
portal
.
unrestrictedTraverse
(
relative_url
)
for
property_
name
in
self
.
_objects
[
relative_url
]:
for
property_
dict
in
self
.
_objects
[
relative_url
]:
obj
.
setProperty
(
property_
name
,
None
)
obj
.
setProperty
(
property_
dict
[
'name'
]
,
None
)
# The reason to keep createInstallationData as separate function is to
# The reason to keep createInstallationData as separate function is to
# not need to initialize an InstallationTree object everytime when we want
# not need to initialize an InstallationTree object everytime when we want
...
...
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