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
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Lu Xu
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):
...
@@ -307,42 +307,41 @@ class TemplateTool (BaseTool):
file
.
seek
(
0
)
file
.
seek
(
0
)
magic
=
file
.
read
(
5
)
magic
=
file
.
read
(
5
)
if
1
:
# XXX: should really check for a magic and offer a falback if it
# XXX: should really check for a magic and offer a falback if it
# doens't correspond to anything handled.
# doens't correspond to anything handled.
tar
=
tarfile
.
open
(
path
,
'r:gz'
)
tar
=
tarfile
.
open
(
path
,
'r:gz'
)
dir_name
=
tar
.
members
[
0
].
name
.
split
(
posixpath
.
sep
,
1
)[
0
]
dir_name
=
tar
.
members
[
0
].
name
.
split
(
posixpath
.
sep
,
1
)[
0
]
try
:
try
:
# create bt object
# create bt object
bt
=
self
.
newContent
(
portal_type
=
'Business Template'
,
id
=
id
)
bt
=
self
.
newContent
(
portal_type
=
'Business Template'
,
id
=
id
)
prop_dict
=
{}
prop_dict
=
{}
for
prop
in
bt
.
propertyMap
():
for
prop
in
bt
.
propertyMap
():
prop_type
=
prop
[
'type'
]
prop_type
=
prop
[
'type'
]
pid
=
prop
[
'id'
]
pid
=
prop
[
'id'
]
prop_path
=
posixpath
.
join
(
dir_name
,
'bt'
,
pid
)
prop_path
=
posixpath
.
join
(
dir_name
,
'bt'
,
pid
)
try
:
try
:
info
=
tar
.
getmember
(
prop_path
)
info
=
tar
.
getmember
(
prop_path
)
value
=
tar
.
extractfile
(
info
).
read
()
value
=
tar
.
extractfile
(
info
).
read
()
except
KeyError
:
except
KeyError
:
value
=
None
value
=
None
if
value
is
'None'
:
if
value
is
'None'
:
# At export time, we used to export non-existent properties:
# At export time, we used to export non-existent properties:
# str(obj.getProperty('non-existing')) == 'None'
# str(obj.getProperty('non-existing')) == 'None'
# Discard them
# Discard them
continue
continue
if
prop_type
in
(
'text'
,
'string'
):
if
prop_type
in
(
'text'
,
'string'
):
prop_dict
[
pid
]
=
value
or
''
prop_dict
[
pid
]
=
value
or
''
elif
prop_type
in
(
'int'
,
'boolean'
):
elif
prop_type
in
(
'int'
,
'boolean'
):
prop_dict
[
pid
]
=
value
or
0
prop_dict
[
pid
]
=
value
or
0
elif
prop_type
in
(
'lines'
,
'tokens'
):
elif
prop_type
in
(
'lines'
,
'tokens'
):
prop_dict
[
pid
[:
-
5
]]
=
(
value
or
''
).
splitlines
()
prop_dict
[
pid
[:
-
5
]]
=
(
value
or
''
).
splitlines
()
prop_dict
.
pop
(
'id'
,
''
)
prop_dict
.
pop
(
'id'
,
''
)
bt
.
edit
(
**
prop_dict
)
bt
.
edit
(
**
prop_dict
)
# import all other files from bt
# import all other files from bt
with
open
(
path
,
'rb'
)
as
fobj
:
with
open
(
path
,
'rb'
)
as
fobj
:
bt
.
importFile
(
file
=
fobj
)
bt
.
importFile
(
file
=
fobj
)
finally
:
finally
:
tar
.
close
()
tar
.
close
()
return
bt
return
bt
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'manage_download'
)
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