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
Ekaterina
erp5
Commits
71d67e7d
Commit
71d67e7d
authored
Jun 06, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BT: code refactoring
parent
1cbed531
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
36 deletions
+17
-36
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+17
-36
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
71d67e7d
...
@@ -62,7 +62,7 @@ from Products.ERP5Type.Utils import readLocalTest, \
...
@@ -62,7 +62,7 @@ from Products.ERP5Type.Utils import readLocalTest, \
from
Products.ERP5Type.Utils
import
convertToUpperCase
from
Products.ERP5Type.Utils
import
convertToUpperCase
from
Products.ERP5Type
import
Permissions
,
PropertySheet
,
interfaces
from
Products.ERP5Type
import
Permissions
,
PropertySheet
,
interfaces
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.dynamic.lazy_class
import
ERP5BaseBroken
,
InitGhostBase
from
Products.ERP5Type.dynamic.lazy_class
import
ERP5BaseBroken
from
Products.ERP5Type.dynamic.portal_type_class
import
synchronizeDynamicModules
from
Products.ERP5Type.dynamic.portal_type_class
import
synchronizeDynamicModules
from
Products.ERP5Type.Core.PropertySheet
import
PropertySheet
as
PropertySheetDocument
from
Products.ERP5Type.Core.PropertySheet
import
PropertySheet
as
PropertySheetDocument
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
...
@@ -89,7 +89,7 @@ import posixpath
...
@@ -89,7 +89,7 @@ import posixpath
import
transaction
import
transaction
import
threading
import
threading
from
ZODB.broken
import
Broken
from
ZODB.broken
import
Broken
,
BrokenModified
from
Products.ERP5.genbt5list
import
BusinessTemplateRevision
,
\
from
Products.ERP5.genbt5list
import
BusinessTemplateRevision
,
\
item_name_list
,
item_set
item_name_list
,
item_set
...
@@ -127,7 +127,7 @@ SEPARATELY_EXPORTED_PROPERTY_DICT = {
...
@@ -127,7 +127,7 @@ SEPARATELY_EXPORTED_PROPERTY_DICT = {
# separate file, with extension specified by 'extension'.
# separate file, with extension specified by 'extension'.
# 'extension' must be None for auto-detection.
# 'extension' must be None for auto-detection.
#
#
# class_name: (extension, property_name),
# class_name: (extension,
unicode_data,
property_name),
"Document Component"
:
(
"py"
,
0
,
"text_content"
),
"Document Component"
:
(
"py"
,
0
,
"text_content"
),
"DTMLMethod"
:
(
None
,
0
,
"raw"
),
"DTMLMethod"
:
(
None
,
0
,
"raw"
),
"Extension Component"
:
(
"py"
,
0
,
"text_content"
),
"Extension Component"
:
(
"py"
,
0
,
"text_content"
),
...
@@ -872,7 +872,18 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -872,7 +872,18 @@ class ObjectTemplateItem(BaseTemplateItem):
# add all datas specific to catalog inside one file
# add all datas specific to catalog inside one file
xml_data
=
self
.
generateXml
(
key
)
xml_data
=
self
.
generateXml
(
key
)
bta
.
addObject
(
xml_data
,
key
+
'.catalog_keys'
,
path
=
path
)
bta
.
addObject
(
xml_data
,
key
+
'.catalog_keys'
,
path
=
path
)
def
_restoreSeparatelyExportedProperty
(
self
,
obj
,
data
):
unicode_data
,
property_name
=
SEPARATELY_EXPORTED_PROPERTY_DICT
[
obj
.
__class__
.
__name__
][
1
:]
if
unicode_data
:
data
=
data
.
decode
(
obj
.
output_encoding
)
try
:
setattr
(
obj
,
property_name
,
data
)
except
BrokenModified
:
obj
.
__Broken_state__
[
property_name
]
=
data
obj
.
_p_changed
=
1
def
_importFile
(
self
,
file_name
,
file_obj
,
catalog_method_template_item
=
0
):
def
_importFile
(
self
,
file_name
,
file_obj
,
catalog_method_template_item
=
0
):
obj_key
,
file_ext
=
os
.
path
.
splitext
(
file_name
)
obj_key
,
file_ext
=
os
.
path
.
splitext
(
file_name
)
# id() for installing several bt5 in the same transaction
# id() for installing several bt5 in the same transaction
...
@@ -892,22 +903,7 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -892,22 +903,7 @@ class ObjectTemplateItem(BaseTemplateItem):
except
KeyError
:
except
KeyError
:
getTransactionalVariable
()[
transactional_variable_obj_key
]
=
data
getTransactionalVariable
()[
transactional_variable_obj_key
]
=
data
else
:
else
:
unicode_data
,
property_name
=
SEPARATELY_EXPORTED_PROPERTY_DICT
[
self
.
_restoreSeparatelyExportedProperty
(
obj
,
data
)
obj
.
__class__
.
__name__
][
1
:]
if
unicode_data
:
data
=
data
.
decode
(
obj
.
output_encoding
)
# if we have instance of InitGhostBase, 'unghost' it so we can
# identify if it is broken
if
isinstance
(
self
.
_objects
[
obj_key
],
InitGhostBase
):
self
.
_objects
[
obj_key
].
__class__
.
loadClass
()
# in case the Portal Type does not exist, the object may be broken.
# So we cannot setattr, but we can change the attribute in its broken state
if
isinstance
(
self
.
_objects
[
obj_key
],
ERP5BaseBroken
):
self
.
_objects
[
obj_key
].
__Broken_state__
[
property_name
]
=
data
self
.
_objects
[
obj_key
].
_p_changed
=
1
else
:
setattr
(
self
.
_objects
[
obj_key
],
property_name
,
data
)
self
.
_objects
[
obj_key
]
=
self
.
removeProperties
(
self
.
_objects
[
obj_key
],
1
,
keep_workflow_history
=
True
)
else
:
else
:
connection
=
self
.
getConnection
(
self
.
aq_parent
)
connection
=
self
.
getConnection
(
self
.
aq_parent
)
__traceback_info__
=
'Importing %s'
%
file_name
__traceback_info__
=
'Importing %s'
%
file_name
...
@@ -921,22 +917,7 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -921,22 +917,7 @@ class ObjectTemplateItem(BaseTemplateItem):
data
=
getTransactionalVariable
().
get
(
transactional_variable_obj_key
)
data
=
getTransactionalVariable
().
get
(
transactional_variable_obj_key
)
if
data
is
not
None
:
if
data
is
not
None
:
unicode_data
,
property_name
=
SEPARATELY_EXPORTED_PROPERTY_DICT
[
self
.
_restoreSeparatelyExportedProperty
(
obj
,
data
)
obj
.
__class__
.
__name__
][
1
:]
if
unicode_data
:
data
=
data
.
decode
(
obj
.
output_encoding
)
# if we have instance of InitGhostBase, 'unghost' it so we can
# identify if it is broken
if
isinstance
(
self
.
_objects
[
obj_key
],
InitGhostBase
):
self
.
_objects
[
obj_key
].
__class__
.
loadClass
()
# in case the related Portal Type does not exist, the object may be broken.
# So we cannot setattr, but we can change the attribute in its broken state
if
isinstance
(
self
.
_objects
[
obj_key
],
ERP5BaseBroken
):
self
.
_objects
[
obj_key
].
__Broken_state__
[
property_name
]
=
data
self
.
_objects
[
obj_key
].
_p_changed
=
1
else
:
setattr
(
self
.
_objects
[
obj_key
],
property_name
,
data
)
self
.
_objects
[
obj_key
]
=
self
.
removeProperties
(
self
.
_objects
[
obj_key
],
1
,
keep_workflow_history
=
True
)
# When importing a Business Template, there is no way to determine if it
# When importing a Business Template, there is no way to determine if it
# has been already migrated or not in __init__() when it does not
# has been already migrated or not in __init__() when it does not
...
...
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