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
020473fa
Commit
020473fa
authored
Dec 12, 2013
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reindent code following removal of Business Template format version 0.
parent
c1746228
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
705 additions
and
721 deletions
+705
-721
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+670
-685
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+35
-36
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
020473fa
This diff is collapsed.
Click to expand it.
product/ERP5/Tool/TemplateTool.py
View file @
020473fa
...
...
@@ -307,42 +307,41 @@ class TemplateTool (BaseTool):
file
.
seek
(
0
)
magic
=
file
.
read
(
5
)
if
1
:
# XXX: should really check for a magic and offer a falback if it
# doens't correspond to anything handled.
tar
=
tarfile
.
open
(
path
,
'r:gz'
)
dir_name
=
tar
.
members
[
0
].
name
.
split
(
posixpath
.
sep
,
1
)[
0
]
try
:
# create bt object
bt
=
self
.
newContent
(
portal_type
=
'Business Template'
,
id
=
id
)
prop_dict
=
{}
for
prop
in
bt
.
propertyMap
():
prop_type
=
prop
[
'type'
]
pid
=
prop
[
'id'
]
prop_path
=
posixpath
.
join
(
dir_name
,
'bt'
,
pid
)
try
:
info
=
tar
.
getmember
(
prop_path
)
value
=
tar
.
extractfile
(
info
).
read
()
except
KeyError
:
value
=
None
if
value
is
'None'
:
# At export time, we used to export non-existent properties:
# str(obj.getProperty('non-existing')) == 'None'
# Discard them
continue
if
prop_type
in
(
'text'
,
'string'
):
prop_dict
[
pid
]
=
value
or
''
elif
prop_type
in
(
'int'
,
'boolean'
):
prop_dict
[
pid
]
=
value
or
0
elif
prop_type
in
(
'lines'
,
'tokens'
):
prop_dict
[
pid
[:
-
5
]]
=
(
value
or
''
).
splitlines
()
prop_dict
.
pop
(
'id'
,
''
)
bt
.
edit
(
**
prop_dict
)
# import all other files from bt
with
open
(
path
,
'rb'
)
as
fobj
:
bt
.
importFile
(
file
=
fobj
)
finally
:
tar
.
close
()
# XXX: should really check for a magic and offer a falback if it
# doens't correspond to anything handled.
tar
=
tarfile
.
open
(
path
,
'r:gz'
)
dir_name
=
tar
.
members
[
0
].
name
.
split
(
posixpath
.
sep
,
1
)[
0
]
try
:
# create bt object
bt
=
self
.
newContent
(
portal_type
=
'Business Template'
,
id
=
id
)
prop_dict
=
{}
for
prop
in
bt
.
propertyMap
():
prop_type
=
prop
[
'type'
]
pid
=
prop
[
'id'
]
prop_path
=
posixpath
.
join
(
dir_name
,
'bt'
,
pid
)
try
:
info
=
tar
.
getmember
(
prop_path
)
value
=
tar
.
extractfile
(
info
).
read
()
except
KeyError
:
value
=
None
if
value
is
'None'
:
# At export time, we used to export non-existent properties:
# str(obj.getProperty('non-existing')) == 'None'
# Discard them
continue
if
prop_type
in
(
'text'
,
'string'
):
prop_dict
[
pid
]
=
value
or
''
elif
prop_type
in
(
'int'
,
'boolean'
):
prop_dict
[
pid
]
=
value
or
0
elif
prop_type
in
(
'lines'
,
'tokens'
):
prop_dict
[
pid
[:
-
5
]]
=
(
value
or
''
).
splitlines
()
prop_dict
.
pop
(
'id'
,
''
)
bt
.
edit
(
**
prop_dict
)
# import all other files from bt
with
open
(
path
,
'rb'
)
as
fobj
:
bt
.
importFile
(
file
=
fobj
)
finally
:
tar
.
close
()
return
bt
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'manage_download'
)
...
...
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