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
143
Merge Requests
143
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
d14b0d1e
Commit
d14b0d1e
authored
Sep 15, 2022
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! py2/py3: Make Products code compatible with both python2 and python3.
parent
bd0d43de
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
36 additions
and
29 deletions
+36
-29
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+9
-7
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+1
-1
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.CachedConvertableMixin.py
...em/portal_components/mixin.erp5.CachedConvertableMixin.py
+1
-4
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.SimulableMixin.py
...mplateItem/portal_components/mixin.erp5.SimulableMixin.py
+2
-1
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_translateString.py
...mplateItem/portal_skins/erp5_core/Base_translateString.py
+3
-1
product/ERP5Form/Tool/SelectionTool.py
product/ERP5Form/Tool/SelectionTool.py
+2
-1
product/ERP5Type/Message.py
product/ERP5Type/Message.py
+6
-6
product/ERP5Type/patches/DA.py
product/ERP5Type/patches/DA.py
+1
-1
product/ERP5Type/tests/ERP5TypeTestCase.py
product/ERP5Type/tests/ERP5TypeTestCase.py
+1
-0
product/ZSQLCatalog/Query/AutoQuery.py
product/ZSQLCatalog/Query/AutoQuery.py
+5
-5
product/ZSQLCatalog/SQLCatalog.py
product/ZSQLCatalog/SQLCatalog.py
+1
-1
product/ZSQLCatalog/SearchText/lexer.py
product/ZSQLCatalog/SearchText/lexer.py
+4
-1
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
d14b0d1e
...
...
@@ -29,7 +29,7 @@
import
six
from
six
import
string_types
as
basestring
from
Products.ERP5Type.Utils
import
ensure_list
,
bytes2str
from
Products.ERP5Type.Utils
import
ensure_list
,
bytes2str
,
str2bytes
import
fnmatch
,
gc
,
glob
,
imp
,
os
,
re
,
shutil
,
sys
,
time
,
tarfile
from
collections
import
defaultdict
from
Shared.DC.ZRDB
import
Aqueduct
...
...
@@ -350,6 +350,8 @@ class BusinessTemplateArchive(object):
self
.
_writeString
(
obj
,
path
)
else
:
if
isinstance
(
obj
,
str
):
obj
=
str2bytes
(
obj
)
if
isinstance
(
obj
,
bytes
):
self
.
revision
.
hash
(
path
,
obj
)
obj
=
BytesIO
(
obj
)
else
:
...
...
@@ -825,7 +827,7 @@ class ObjectTemplateItem(BaseTemplateItem):
obj
=
obj
.
_getCopy
(
context
)
data
=
getattr
(
aq_base
(
obj
),
record_id
,
None
)
if
unicode_data
:
if
not
isinstance
(
data
,
six
.
text_type
):
if
not
(
six
.
PY2
and
isinstance
(
data
,
six
.
text_type
)
):
break
try
:
data
=
data
.
encode
(
aq_base
(
obj
).
output_encoding
)
...
...
@@ -3523,7 +3525,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
path
=
self
.
__class__
.
__name__
for
key
in
self
.
_objects
:
xml_data
=
self
.
generateXml
(
key
)
if
isinstance
(
xml_data
,
six
.
text_type
):
if
six
.
PY2
and
isinstance
(
xml_data
,
six
.
text_type
):
xml_data
=
xml_data
.
encode
(
'utf-8'
)
name
=
key
.
split
(
'/'
,
1
)[
1
]
bta
.
addObject
(
xml_data
,
name
=
name
,
path
=
path
)
...
...
@@ -3537,7 +3539,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
xml_type_roles_list
=
xml
.
findall
(
'role'
)
for
role
in
xml_type_roles_list
:
id
=
role
.
get
(
'id'
)
if
isinstance
(
id
,
six
.
text_type
):
if
six
.
PY2
and
isinstance
(
id
,
six
.
text_type
):
id
=
id
.
encode
(
'utf_8'
,
'backslashreplace'
)
type_role_property_dict
=
{
'id'
:
id
}
# uniq
...
...
@@ -3546,7 +3548,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
property_id
=
property_node
.
get
(
'id'
)
if
property_node
.
text
:
value
=
property_node
.
text
if
isinstance
(
value
,
six
.
text_type
):
if
six
.
PY2
and
isinstance
(
value
,
six
.
text_type
):
value
=
value
.
encode
(
'utf_8'
,
'backslashreplace'
)
type_role_property_dict
[
property_id
]
=
value
# multi
...
...
@@ -3555,7 +3557,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
property_id
=
property_node
.
get
(
'id'
)
if
property_node
.
text
:
value
=
property_node
.
text
if
isinstance
(
value
,
six
.
text_type
):
if
six
.
PY2
and
isinstance
(
value
,
six
.
text_type
):
value
=
value
.
encode
(
'utf_8'
,
'backslashreplace'
)
type_role_property_dict
.
setdefault
(
property_id
,
[]).
append
(
value
)
type_roles_list
.
append
(
type_role_property_dict
)
...
...
@@ -4964,7 +4966,7 @@ class LocalRolesTemplateItem(BaseTemplateItem):
xml_data
+=
'
\
n
</local_role_group_ids>'
xml_data
+=
'
\
n
</local_roles_item>'
if
isinstance
(
xml_data
,
six
.
text_type
):
if
six
.
PY2
and
isinstance
(
xml_data
,
six
.
text_type
):
xml_data
=
xml_data
.
encode
(
'utf8'
)
return
xml_data
...
...
product/ERP5/Tool/TemplateTool.py
View file @
d14b0d1e
...
...
@@ -1066,7 +1066,7 @@ class TemplateTool (BaseTool):
installed_revision=installed_revision,
repository=repository,
**property_dict)
obj.setUid(
uid
)
obj.setUid(
bytes2str(uid)
)
result_list.append(obj)
result_list.sort(key=lambda x: x.getTitle())
return result_list
...
...
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.CachedConvertableMixin.py
View file @
d14b0d1e
...
...
@@ -54,10 +54,7 @@ def hashPdataObject(pdata_object):
while
pdata_object
is
not
None
:
chunk
=
pdata_object
.
aq_base
md5_hash
.
update
(
chunk
.
data
)
if
six
.
PY2
:
pdata_object
=
chunk
.
next
else
:
pdata_object
=
chunk
.
__next__
pdata_object
=
chunk
.
next
chunk
.
_p_deactivate
()
return
md5_hash
.
hexdigest
()
...
...
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.SimulableMixin.py
View file @
d14b0d1e
...
...
@@ -34,6 +34,7 @@ from Products.ERP5Type.Globals import InitializeClass
from
Products.ERP5Type.Base
import
Base
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.Errors
import
SimulationError
from
Products.ERP5Type.Utils
import
ensure_list
SIMULATION_PRIORITY
=
3
...
...
@@ -77,7 +78,7 @@ class SimulableMixin(Base):
ignore
.
update
(
kw
)
tv
[
ignore_key
]
=
ignore
transaction
.
get
().
addBeforeCommitHook
(
before_commit
)
for
k
,
v
in
item_list
:
for
k
,
v
in
ensure_list
(
item_list
)
:
if
not
v
:
ignore
.
add
(
k
)
elif
k
not
in
ignore
:
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_translateString.py
View file @
d14b0d1e
...
...
@@ -12,8 +12,10 @@ if translation_service is not None :
if
not
encoding
:
return
translation_service
.
translate
(
catalog
,
msg
,
lang
=
lang
,
**
kw
)
msg
=
translation_service
.
translate
(
catalog
,
msg
,
lang
=
lang
,
**
kw
)
if
isinstance
(
msg
,
six
.
text_type
):
if
six
.
PY2
and
isinstance
(
msg
,
six
.
text_type
):
msg
=
msg
.
encode
(
encoding
)
elif
six
.
PY3
and
isinstance
(
msg
,
six
.
binary_type
):
msg
=
msg
.
decode
(
encoding
)
return
msg
except
AttributeError
:
# This happens in unit testing, because it is not able to find something with get_context()
pass
...
...
product/ERP5Form/Tool/SelectionTool.py
View file @
d14b0d1e
...
...
@@ -32,6 +32,7 @@
"""
from
OFS.SimpleItem
import
SimpleItem
from
Products.ERP5Type.Utils
import
ensure_list
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
,
PersistentMapping
,
get_request
from
AccessControl
import
ClassSecurityInfo
from
ZTUtils
import
make_query
...
...
@@ -434,7 +435,7 @@ class SelectionTool( BaseTool, SimpleItem ):
selection_uid_dict
[
int
(
uid
)]
=
1
except
(
ValueError
,
TypeError
):
selection_uid_dict
[
uid
]
=
1
self
.
setSelectionCheckedUidsFor
(
list_selection_name
,
selection_uid_dict
.
keys
(
),
REQUEST
=
REQUEST
)
self
.
setSelectionCheckedUidsFor
(
list_selection_name
,
ensure_list
(
selection_uid_dict
.
keys
()
),
REQUEST
=
REQUEST
)
if
REQUEST
is
not
None
:
return
self
.
_redirectToOriginalForm
(
REQUEST
=
REQUEST
,
form_id
=
form_id
,
query_string
=
query_string
,
no_reset
=
True
)
...
...
product/ERP5Type/Message.py
View file @
d14b0d1e
...
...
@@ -114,7 +114,7 @@ class Message(Persistent):
if
self
.
domain
is
None
:
# Map the translated string with given parameters
if
type
(
self
.
mapping
)
is
dict
:
if
isinstance
(
message
,
six
.
text_type
)
:
if
six
.
PY2
and
isinstance
(
message
,
six
.
text_type
)
:
message
=
message
.
encode
(
'utf-8'
)
message
=
Template
(
message
).
substitute
(
self
.
mapping
)
else
:
...
...
@@ -124,7 +124,7 @@ class Message(Persistent):
if
self
.
mapping
:
unicode_mapping
=
{}
for
k
,
v
in
six
.
iteritems
(
self
.
mapping
):
if
isinstance
(
v
,
str
):
if
six
.
PY2
and
isinstance
(
v
,
str
):
v
=
v
.
decode
(
'utf-8'
)
unicode_mapping
[
k
]
=
v
else
:
...
...
@@ -139,9 +139,9 @@ class Message(Persistent):
message
=
translated_message
if
isinstance
(
self
.
message
,
str
):
if
isinstance
(
message
,
six
.
text_type
):
if
six
.
PY2
and
isinstance
(
message
,
six
.
text_type
):
message
=
message
.
encode
(
'utf-8'
)
elif
isinstance
(
message
,
str
):
elif
six
.
PY2
and
isinstance
(
message
,
str
):
message
=
message
.
decode
(
'utf-8'
)
return
message
...
...
@@ -154,7 +154,7 @@ class Message(Persistent):
Return the translated message as a string object.
"""
message
=
self
.
translate
()
if
isinstance
(
message
,
six
.
text_type
):
if
six
.
PY2
and
isinstance
(
message
,
six
.
text_type
):
message
=
message
.
encode
(
'utf-8'
)
return
message
...
...
@@ -163,7 +163,7 @@ class Message(Persistent):
Return the translated message as a unicode object.
"""
message
=
self
.
translate
()
if
isinstance
(
message
,
str
):
if
six
.
PY2
and
isinstance
(
message
,
str
):
message
=
message
.
decode
(
'utf-8'
)
return
message
...
...
product/ERP5Type/patches/DA.py
View file @
d14b0d1e
...
...
@@ -219,7 +219,7 @@ def DA__call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw):
if
src__
:
return
query
if
self
.
cache_time_
>
0
and
self
.
max_cache_
>
0
:
result
=
self
.
_cached_result
(
DB__
,
query
,
self
.
max_rows_
,
c
)
result
=
self
.
_cached_result
(
DB__
,
str2bytes
(
query
)
,
self
.
max_rows_
,
c
)
else
:
try
:
result
=
DB__
.
query
(
query
,
self
.
max_rows_
)
...
...
product/ERP5Type/tests/ERP5TypeTestCase.py
View file @
d14b0d1e
...
...
@@ -18,6 +18,7 @@ import string
import
sys
import
time
import
traceback
import
urllib
from
six.moves
import
configparser
from
contextlib
import
contextmanager
from
io
import
BytesIO
...
...
product/ZSQLCatalog/Query/AutoQuery.py
View file @
d14b0d1e
...
...
@@ -76,17 +76,17 @@ class AutoQuery(Query):
# Recreate value as a dict and pass it to buildSingleQuery.
range
=
kw
.
pop
(
'range'
)
assert
len
(
kw
)
==
1
,
repr
(
kw
)
key
,
value
=
kw
.
items
(
)[
0
]
key
,
value
=
list
(
kw
.
items
()
)[
0
]
query
=
sql_catalog
.
buildSingleQuery
(
key
,
{
'query'
:
value
,
'range'
:
range
})
elif
operator
==
'in'
:
# 'in' is a *comparison* operator, not a logical operator.
# Transform kw into the proper form.
assert
len
(
kw
)
==
1
,
repr
(
kw
)
key
,
value
=
kw
.
items
(
)[
0
]
key
,
value
=
list
(
kw
.
items
()
)[
0
]
query
=
sql_catalog
.
buildSingleQuery
(
key
,
{
'query'
:
value
,
'operator'
:
operator
})
elif
len
(
kw
)
==
1
and
isinstance
(
kw
.
values
(
)[
0
],
(
tuple
,
list
))
and
\
elif
len
(
kw
)
==
1
and
isinstance
(
list
(
kw
.
values
()
)[
0
],
(
tuple
,
list
))
and
\
operator
in
(
'and'
,
'or'
):
# If there is only one parameter, and operator was given and is a
# known logical operator, then operator will apply to it.
...
...
@@ -94,7 +94,7 @@ class AutoQuery(Query):
# kw = {'portal_type': ['!=a', '!=b'], 'operator': 'AND'}
# In such case, expected result is
# "portal_type!='a' AND portal_type!='b'"
key
,
value
=
kw
.
items
(
)[
0
]
key
,
value
=
list
(
kw
.
items
()
)[
0
]
query
=
sql_catalog
.
buildSingleQuery
(
key
,
value
,
logical_operator
=
operator
)
else
:
# Otherwise, the operator will apply to the relationship between
...
...
@@ -102,7 +102,7 @@ class AutoQuery(Query):
if
operator
is
None
:
operator
=
'and'
if
self
.
search_key
is
not
None
:
key
,
value
=
kw
.
items
(
)[
0
]
key
,
value
=
list
(
kw
.
items
()
)[
0
]
kw
=
{
key
:
{
'query'
:
value
,
'key'
:
self
.
search_key
}}
query
=
sql_catalog
.
buildQuery
(
kw
,
operator
=
operator
,
ignore_empty_string
=
self
.
ignore_empty_string
)
if
self
.
table_alias_list
is
not
None
:
...
...
product/ZSQLCatalog/SQLCatalog.py
View file @
d14b0d1e
...
...
@@ -2129,7 +2129,7 @@ class Catalog(Folder,
if
len
(
empty_value_dict
):
LOG
(
'SQLCatalog'
,
WARNING
,
'Discarding columns with empty values: %r'
%
(
empty_value_dict
,
))
if
len
(
unknown_column_dict
):
message
=
'Unknown columns '
+
repr
(
unknown_column_dict
.
keys
(
))
message
=
'Unknown columns '
+
repr
(
ensure_list
(
unknown_column_dict
.
keys
()
))
if
ignore_unknown_columns
:
LOG
(
'SQLCatalog'
,
WARNING
,
message
)
else
:
...
...
product/ZSQLCatalog/SearchText/lexer.py
View file @
d14b0d1e
...
...
@@ -58,7 +58,10 @@ class lexer(object):
write_tables
=
False
)
sys
.
stdout
,
sys
.
stderr
=
sys
.
__stdout__
,
sys
.
__stderr__
# Emit all logs with regular Zope logging
for
line
in
output
.
getvalue
().
split
(
'
\
n
'
):
value
=
output
.
getvalue
()
if
six
.
PY3
:
value
=
value
.
decode
()
for
line
in
value
.
split
(
'
\
n
'
):
if
len
(
line
):
LOG
(
'lexer'
,
0
,
line
)
...
...
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