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
Labels
Merge Requests
138
Merge Requests
138
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
1bc2d5ef
Commit
1bc2d5ef
authored
Jul 21, 2023
by
Emmy Vouriot
Committed by
Arnaud Fontaine
Jul 04, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: Python 2 to 3 fixes - add py2 compatibility
parent
173bf646
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
product/ERP5Form/ImageField.py
product/ERP5Form/ImageField.py
+3
-0
product/ERP5OOo/FormPrintout.py
product/ERP5OOo/FormPrintout.py
+6
-2
No files found.
product/ERP5Form/ImageField.py
View file @
1bc2d5ef
...
@@ -34,6 +34,7 @@ from OFS.Image import Image as OFSImage
...
@@ -34,6 +34,7 @@ from OFS.Image import Image as OFSImage
from
lxml.etree
import
Element
from
lxml.etree
import
Element
from
lxml
import
etree
from
lxml
import
etree
import
re
import
re
import
six
DRAW_URI
=
'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'
DRAW_URI
=
'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'
TEXT_URI
=
'urn:oasis:names:tc:opendocument:xmlns:text:1.0'
TEXT_URI
=
'urn:oasis:names:tc:opendocument:xmlns:text:1.0'
...
@@ -145,6 +146,8 @@ class ImageFieldWidget(Widget.TextWidget):
...
@@ -145,6 +146,8 @@ class ImageFieldWidget(Widget.TextWidget):
if
value
in
(
''
,
None
):
if
value
in
(
''
,
None
):
return
None
return
None
path
=
'/'
.
join
(
REQUEST
.
physicalPathFromURL
(
value
))
path
=
'/'
.
join
(
REQUEST
.
physicalPathFromURL
(
value
))
if
six
.
PY2
:
path
=
path
.
encode
()
image_object
=
field
.
getPortalObject
().
restrictedTraverse
(
path
)
image_object
=
field
.
getPortalObject
().
restrictedTraverse
(
path
)
display
=
field
.
get_value
(
'image_display'
)
display
=
field
.
get_value
(
'image_display'
)
format
=
field
.
get_value
(
'image_format'
)
format
=
field
.
get_value
(
'image_format'
)
...
...
product/ERP5OOo/FormPrintout.py
View file @
1bc2d5ef
...
@@ -1107,8 +1107,12 @@ class ODGStrategy(ODFStrategy):
...
@@ -1107,8 +1107,12 @@ class ODGStrategy(ODFStrategy):
text_xpath = '//draw:frame[@draw:name="
%
s
"]' % field.id
text_xpath = '//draw:frame[@draw:name="
%
s
"]' % field.id
node_list = element_tree.xpath(text_xpath, namespaces=element_tree.nsmap)
node_list = element_tree.xpath(text_xpath, namespaces=element_tree.nsmap)
value = field.get_value('default')
value = field.get_value('default')
if isinstance(value, bytes):
if six.PY2:
value = value.decode('utf-8')
if isinstance(value, str):
value = value.decode('utf-8')
else:
if isinstance(value, bytes):
value = value.decode('utf-8')
for target_node in node_list:
for target_node in node_list:
# render the field in odg xml node format
# render the field in odg xml node format
attr_dict = {}
attr_dict = {}
...
...
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