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
Levin Zimmermann
erp5
Commits
e3e53b04
Commit
e3e53b04
authored
Mar 31, 2022
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
bc39dd99
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
39 deletions
+58
-39
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+51
-30
product/ERP5/ERP5Site.py
product/ERP5/ERP5Site.py
+1
-0
product/ERP5Type/patches/ppml.py
product/ERP5Type/patches/ppml.py
+6
-9
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
e3e53b04
...
...
@@ -141,33 +141,41 @@ SEPARATELY_EXPORTED_PROPERTY_DICT = {
# separate file, with extension specified by 'extension'.
# 'extension' must be None for auto-detection.
#
# class_name: (extension, unicode_data, property_name),
"Document Component"
:
(
"py"
,
0
,
"text_content"
),
"DTMLDocument"
:
(
None
,
0
,
"raw"
),
"DTMLMethod"
:
(
None
,
0
,
"raw"
),
"Extension Component"
:
(
"py"
,
0
,
"text_content"
),
"File"
:
(
None
,
0
,
"data"
),
"Image"
:
(
None
,
0
,
"data"
),
"Interface Component"
:
(
"py"
,
0
,
"text_content"
),
"OOoTemplate"
:
(
"oot"
,
1
,
"_text"
),
"Mixin Component"
:
(
"py"
,
0
,
"text_content"
),
"Module Component"
:
(
"py"
,
0
,
"text_content"
),
"PDF"
:
(
"pdf"
,
0
,
"data"
),
"PyData Script"
:
(
"py"
,
0
,
"_body"
),
"Python Script"
:
(
"py"
,
0
,
"_body"
),
"Workflow Script"
:
(
"py"
,
0
,
"_body"
),
"PythonScript"
:
(
"py"
,
0
,
"_body"
),
"Spreadsheet"
:
(
None
,
0
,
"data"
),
"SQL"
:
(
"sql"
,
0
,
"src"
),
"SQL Method"
:
(
"sql"
,
0
,
"src"
),
"Test Component"
:
(
"py"
,
0
,
"text_content"
),
"Test Page"
:
(
None
,
0
,
"text_content"
),
"Tool Component"
:
(
"py"
,
0
,
"text_content"
),
"Web Illustration"
:
(
"svg"
,
0
,
"text_content"
),
"Web Page"
:
(
None
,
0
,
"text_content"
),
"Web Script"
:
(
None
,
0
,
"text_content"
),
"Web Style"
:
(
None
,
0
,
"text_content"
),
"ZopePageTemplate"
:
(
"zpt"
,
1
,
"_text"
),
# class_name: (extension, unicode_data, property_name, text),
"Document Component"
:
(
"py"
,
0
,
"text_content"
,
True
),
"DTMLDocument"
:
(
None
,
0
,
"raw"
,
True
),
"DTMLMethod"
:
(
None
,
0
,
"raw"
,
True
),
"Extension Component"
:
(
"py"
,
0
,
"text_content"
,
True
),
"File"
:
(
None
,
0
,
"data"
,
lambda
obj
:
(
obj
.
content_type
.
startswith
(
'text/'
)
or
obj
.
content_type
in
(
'application/javascript'
,
'application/js'
,
'application/json'
,
'application/schema+json'
,
'application/x-javascript'
,
'application/xml'
,
'application/x-php'
,
'image/svg+xml'
))),
"Image"
:
(
None
,
0
,
"data"
,
False
),
"Interface Component"
:
(
"py"
,
0
,
"text_content"
,
True
),
"OOoTemplate"
:
(
"oot"
,
1
,
"_text"
,
True
),
"Mixin Component"
:
(
"py"
,
0
,
"text_content"
,
True
),
"Module Component"
:
(
"py"
,
0
,
"text_content"
,
True
),
"PDF"
:
(
"pdf"
,
0
,
"data"
,
False
),
"PyData Script"
:
(
"py"
,
0
,
"_body"
,
True
),
"Python Script"
:
(
"py"
,
0
,
"_body"
,
True
),
"Workflow Script"
:
(
"py"
,
0
,
"_body"
,
True
),
"PythonScript"
:
(
"py"
,
0
,
"_body"
,
True
),
"Spreadsheet"
:
(
None
,
0
,
"data"
,
False
),
"SQL"
:
(
"sql"
,
0
,
"src"
,
True
),
"SQL Method"
:
(
"sql"
,
0
,
"src"
,
True
),
"Test Component"
:
(
"py"
,
0
,
"text_content"
,
True
),
"Test Page"
:
(
None
,
0
,
"text_content"
,
True
),
"Tool Component"
:
(
"py"
,
0
,
"text_content"
,
True
),
"Web Illustration"
:
(
"svg"
,
0
,
"text_content"
,
True
),
"Web Page"
:
(
None
,
0
,
"text_content"
,
True
),
"Web Script"
:
(
None
,
0
,
"text_content"
,
True
),
"Web Style"
:
(
None
,
0
,
"text_content"
,
True
),
"ZopePageTemplate"
:
(
"zpt"
,
1
,
"_text"
,
True
),
}
def
_getCatalog
(
acquisition_context
):
...
...
@@ -823,7 +831,7 @@ class ObjectTemplateItem(BaseTemplateItem):
bta
.
addObject
(
obj
,
name
=
key
,
ext
=
'.py'
)
else
:
try
:
extension
,
unicode_data
,
record_id
=
\
extension
,
unicode_data
,
record_id
,
_
=
\
SEPARATELY_EXPORTED_PROPERTY_DICT
[
obj
.
__class__
.
__name__
]
except
KeyError
:
pass
...
...
@@ -877,10 +885,14 @@ class ObjectTemplateItem(BaseTemplateItem):
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
:]
class_name
=
obj
.
__class__
.
__name__
unicode_data
,
property_name
,
is_text
=
SEPARATELY_EXPORTED_PROPERTY_DICT
[
class_name
][
1
:]
if
unicode_data
:
data
=
data
.
decode
(
obj
.
output_encoding
)
elif
((
callable
(
is_text
)
and
is_text
(
obj
))
or
(
not
callable
(
is_text
)
and
is_text
)):
data
=
data
.
decode
(
'utf-8'
)
try
:
setattr
(
obj
,
property_name
,
data
)
except
BrokenModified
:
...
...
@@ -897,6 +909,7 @@ class ObjectTemplateItem(BaseTemplateItem):
obj_key
,
file_ext
=
os
.
path
.
splitext
(
file_name
)
# id() for installing several bt5 in the same transaction
transactional_variable_obj_key
=
"%s-%s"
%
(
id
(
self
),
obj_key
)
obj
=
None
if
file_ext
!=
'.xml'
:
# if the document has not been migrated yet (its class is file and
# it is not in portal_components) use legacy importer
...
...
@@ -943,6 +956,12 @@ class ObjectTemplateItem(BaseTemplateItem):
pass
if
catalog_method_template_item
:
self
.
removeProperties
(
obj
,
0
)
if
obj
is
not
None
:
bytes_item_list
=
[(
k
,
v
)
for
k
,
v
in
obj
.
__dict__
.
items
()
if
isinstance
(
k
,
bytes
)
or
isinstance
(
v
,
bytes
)
]
if
bytes_item_list
:
print
(
"%r: %s"
%
(
getattr
(
obj
,
'content_type'
,
None
),
file_name
))
import
pdb
;
pdb
.
set_trace
()
def
build_sub_objects
(
self
,
context
,
id_list
,
url
,
**
kw
):
# XXX duplicates code from build
...
...
@@ -3954,6 +3973,7 @@ class FilesystemDocumentTemplateItem(BaseTemplateItem):
LOG
(
'Business Template'
,
0
,
'Skipping file "%s"'
%
(
file_name
,
))
return
text
=
file
.
read
()
import
pdb
;
pdb
.
set_trace
()
self
.
_objects
[
file_name
[:
-
3
]]
=
text
class
FilesystemToZodbTemplateItem
(
FilesystemDocumentTemplateItem
,
...
...
@@ -4885,6 +4905,7 @@ class MessageTranslationTemplateItem(BaseTemplateItem):
bta
.
addObject
(
'
\
n
'
.
join
(
xml_data
),
'language'
,
path
=
path
)
def
_importFile
(
self
,
file_name
,
file
):
import
pdb
;
pdb
.
set_trace
()
name
=
posixpath
.
split
(
file_name
)[
1
]
if
name
==
'translation.po'
:
text
=
file
.
read
()
...
...
product/ERP5/ERP5Site.py
View file @
e3e53b04
...
...
@@ -2524,6 +2524,7 @@ def initialize(self):
time
.
sleep
(
5
)
except
:
import
pdb
;
pdb
.
post_mortem
()
raise
from
Products.TimerService.timerserver.TimerServer
import
TimerRequest
def
traverse
(
*
args
,
**
kw
):
del
TimerRequest
.
traverse
...
...
product/ERP5Type/patches/ppml.py
View file @
e3e53b04
...
...
@@ -83,7 +83,7 @@ def unconvert(encoding,S):
if
encoding
==
'base64'
:
return
base64
.
decodestring
(
S
)
else
:
return
bytes
(
eval
(
b"'"
+
S
.
replace
(
b'
\
n
'
,
b''
)
+
b"'"
),
'utf-8'
)
return
eval
(
b"'"
+
S
.
replace
(
b'
\
n
'
,
b''
)
+
b"'"
).
encode
(
'utf-8'
)
ppml
.
unconvert
=
unconvert
...
...
@@ -328,9 +328,8 @@ class NoBlanks(object):
"""
# Ignore element data between elements (eg '<e> <f> </f> </e>')...
if
data
.
strip
():
if
isinstance
(
data
,
bytes
):
import
pdb
;
pdb
.
set_trace
()
data
=
data
.
encode
(
'raw_unicode_escape'
)
if
isinstance
(
data
,
str
):
data
=
data
.
encode
(
'utf-8'
)
self
.
append
(
data
)
# Except for strings and unicode data as whitespaces should be
...
...
@@ -353,9 +352,8 @@ class NoBlanks(object):
self
.
previous_discarded_data
=
None
self
.
previous_stack_end
=
None
if
isinstance
(
data
,
bytes
):
import
pdb
;
pdb
.
set_trace
()
data
=
data
.
encode
(
'raw_unicode_escape'
)
if
isinstance
(
data
,
str
):
data
=
data
.
encode
(
'utf-8'
)
self
.
append
(
data
)
...
...
@@ -769,8 +767,7 @@ class xmlPickler(NoBlanks, xyap):
if
tag
in
end
:
top
=
end
[
tag
](
self
,
tag
,
top
)
if
isinstance
(
top
,
str
):
import
pdb
;
pdb
.
set_trace
()
top
=
top
.
encode
(
'raw_unicode_escape'
)
top
=
top
.
encode
(
'utf-8'
)
append
(
top
)
start_handlers
=
{
...
...
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