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
6db3464c
Commit
6db3464c
authored
Apr 06, 2022
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py3: More bytes()/str() fixups.
parent
3819e97f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
19 deletions
+51
-19
product/ERP5Form/ListBox.py
product/ERP5Form/ListBox.py
+43
-14
product/ERP5Form/Tool/SelectionTool.py
product/ERP5Form/Tool/SelectionTool.py
+5
-2
product/ERP5Type/Accessor/Translation.py
product/ERP5Type/Accessor/Translation.py
+1
-1
product/ERP5Type/Accessor/WorkflowState.py
product/ERP5Type/Accessor/WorkflowState.py
+2
-2
No files found.
product/ERP5Form/ListBox.py
View file @
6db3464c
...
...
@@ -58,6 +58,7 @@ from Products.PythonScripts.Utility import allow_class
from
Products.PageTemplates.PageTemplateFile
import
PageTemplateFile
from
warnings
import
warn
import
cgi
import
six
DEFAULT_LISTBOX_DISPLAY_STYLE
=
'table'
DEFAULT_LISTBOX_PAGE_NAVIGATION_TEMPLATE
=
'ListBox_viewSliderPageNavigationRenderer'
...
...
@@ -672,7 +673,7 @@ class ListBoxRenderer(object):
def
getTitle
(
self
):
"""Return the title. Make sure that it is in unicode.
"""
return
s
tr
(
self
.
field
.
get_value
(
'title'
),
self
.
getEncoding
()
)
return
s
elf
.
field
.
get_value
(
'title'
)
def
getMaxLineNumber
(
self
):
"""Return the maximum number of lines shown in a page.
...
...
@@ -861,7 +862,10 @@ class ListBoxRenderer(object):
"""Return the columns. Make sure that the titles are in unicode.
"""
columns
=
self
.
field
.
get_value
(
'columns'
)
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
columns
]
if
six
.
PY3
:
return
columns
else
:
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
columns
]
@
lazyMethod
def
getAllColumnList
(
self
):
...
...
@@ -870,9 +874,14 @@ class ListBoxRenderer(object):
"""
all_column_list
=
list
(
self
.
getColumnList
())
all_column_id_set
=
{
c
[
0
]
for
c
in
all_column_list
}
all_column_list
.
extend
((
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
self
.
field
.
get_value
(
'all_columns'
)
if
c
[
0
]
not
in
all_column_id_set
)
if
six
.
PY3
:
all_column_list
.
extend
(
c
for
c
in
self
.
field
.
get_value
(
'all_columns'
)
if
c
[
0
]
not
in
all_column_id_set
)
else
:
all_column_list
.
extend
((
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
self
.
field
.
get_value
(
'all_columns'
)
if
c
[
0
]
not
in
all_column_id_set
)
return
all_column_list
@
lazyMethod
...
...
@@ -887,7 +896,10 @@ class ListBoxRenderer(object):
"""
stat_columns
=
self
.
field
.
get_value
(
'stat_columns'
)
if
stat_columns
:
stat_column_list
=
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
stat_columns
]
if
six
.
PY3
:
stat_column_list
=
stat_columns
else
:
stat_column_list
=
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
stat_columns
]
else
:
stat_column_list
=
[(
c
[
0
],
c
[
0
])
for
c
in
self
.
getAllColumnList
()]
return
stat_column_list
...
...
@@ -917,21 +929,30 @@ class ListBoxRenderer(object):
"""Return the domain root list. Make sure that the titles are in unicode.
"""
domain_root_list
=
self
.
field
.
get_value
(
'domain_root_list'
)
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
domain_root_list
]
if
six
.
PY3
:
return
domain_root_list
else
:
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
domain_root_list
]
@
lazyMethod
def
getReportRootList
(
self
):
"""Return the report root list. Make sure that the titles are in unicode.
"""
report_root_list
=
self
.
field
.
get_value
(
'report_root_list'
)
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
report_root_list
]
if
six
.
PY3
:
return
report_root_list
else
:
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
report_root_list
]
@
lazyMethod
def
getDisplayStyleList
(
self
):
"""Return the list of avaible display style. Make sure that the
titles are in unicode"""
display_style_list
=
self
.
field
.
get_value
(
'display_style_list'
)
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
\
if
six
.
PY3
:
return
display_style_list
else
:
return
[(
str
(
c
[
0
]),
str
(
c
[
1
],
self
.
getEncoding
()))
for
c
in
\
display_style_list
]
@
lazyMethod
...
...
@@ -1606,7 +1627,7 @@ class ListBoxRenderer(object):
param
=
param_dict
.
get
(
alias
,
param_dict
.
get
(
sql
,
u''
))
if
isinstance
(
param
,
dict
):
param
=
param
.
get
(
'query'
,
u''
)
if
isinstance
(
param
,
str
):
if
isinstance
(
param
,
bytes
):
param
=
str
(
param
,
self
.
getEncoding
())
# Obtain a search field, if any.
...
...
@@ -1690,7 +1711,11 @@ class ListBoxRenderer(object):
processed_value
=
editable_field
.
render_view
(
value
=
original_value
)
if
not
isinstance
(
processed_value
,
str
):
processed_value
=
str
(
str
(
processed_value
),
self
.
getEncoding
(),
'replace'
)
if
six
.
PY3
:
processed_value
=
str
(
processed_value
).
encode
(
self
.
getEncoding
(),
'replace'
).
decode
()
else
:
processed_value
=
str
(
str
(
processed_value
),
self
.
getEncoding
(),
'replace'
)
value_list
.
append
((
original_value
,
processed_value
))
...
...
@@ -2284,7 +2309,11 @@ class ListBoxRendererLine(object):
if
processed_value
is
None
:
processed_value
=
u''
elif
not
isinstance
(
processed_value
,
str
):
processed_value
=
str
(
str
(
processed_value
),
renderer
.
getEncoding
(),
'replace'
)
if
six
.
PY3
:
processed_value
=
str
(
processed_value
).
encode
(
renderer
.
getEncoding
(),
'replace'
).
decode
()
else
:
processed_value
=
str
(
str
(
processed_value
),
renderer
.
getEncoding
(),
'replace'
)
value_list
.
append
((
original_value
,
processed_value
))
...
...
@@ -2398,7 +2427,7 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
except
AttributeError
:
pass
if
isinstance
(
url
,
str
):
if
isinstance
(
url
,
bytes
):
url
=
str
(
url
,
encoding
)
if
editable_field
is
not
None
:
...
...
@@ -2462,7 +2491,7 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
editable
=
(
not
self
.
isSummary
())
\
and
listbox_defines_column_as_editable
and
editable
,
)
if
isinstance
(
cell_html
,
str
):
if
isinstance
(
cell_html
,
bytes
):
cell_html
=
str
(
cell_html
,
encoding
)
else
:
cell_html
=
u''
...
...
product/ERP5Form/Tool/SelectionTool.py
View file @
6db3464c
...
...
@@ -54,7 +54,7 @@ from Acquisition import aq_base
from
Products.ERP5Type.Message
import
translateString
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
,
ComplexQuery
import
warnings
import
six
_MARKER
=
[]
...
...
@@ -1227,7 +1227,10 @@ class SelectionTool( BaseTool, SimpleItem ):
return
None
# XXX To avoid the difference of the string representations of int and long,
# convert each element to a string.
return
md5
(
str
(
sorted
(
map
(
str
,
uid_list
)))).
hexdigest
()
if
six
.
PY3
:
return
md5
(
str
(
sorted
(
uid_list
)).
encode
()).
hexdigest
()
else
:
return
md5
(
str
(
sorted
(
map
(
str
,
uid_list
)))).
hexdigest
()
# Related document searching
security
.
declarePublic
(
'viewSearchRelatedDocumentDialog'
)
...
...
product/ERP5Type/Accessor/Translation.py
View file @
6db3464c
...
...
@@ -86,7 +86,7 @@ class TranslatedPropertyGetter(BaseGetter):
localizer
=
instance
.
getPortalObject
().
Localizer
message_catalog
=
getattr
(
localizer
,
domain
,
None
)
if
message_catalog
is
not
None
:
return
message_catalog
.
gettext
(
str
(
value
,
'utf8'
),
lang
=
self
.
_language
).
encode
(
'utf8'
)
return
message_catalog
.
gettext
(
value
,
lang
=
self
.
_language
)
else
:
return
value
...
...
product/ERP5Type/Accessor/WorkflowState.py
View file @
6db3464c
...
...
@@ -97,7 +97,7 @@ class TranslatedGetter(Getter):
state_id
=
wf
.
_getWorkflowStateOf
(
instance
,
id_only
=
1
)
warn
(
'Translated workflow state getters, such as %s are deprecated'
%
self
.
_id
,
DeprecationWarning
)
return
portal
.
Localizer
.
erp5_ui
.
gettext
(
state_id
)
.
encode
(
'utf8'
)
return
portal
.
Localizer
.
erp5_ui
.
gettext
(
state_id
)
psyco
.
bind
(
__call__
)
...
...
@@ -120,7 +120,7 @@ class TranslatedTitleGetter(TitleGetter):
if
result
==
''
:
result
=
localizer
.
erp5_ui
.
gettext
(
state_title
,
lang
=
selected_language
)
return
result
.
encode
(
'utf8'
)
return
result
psyco
.
bind
(
__call__
)
...
...
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