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
137
Merge Requests
137
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
86829ed4
Commit
86829ed4
authored
Oct 12, 2024
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP-encode-decode: fixup! IdTool: handle group_id on python3
parent
586d943b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testIdTool.py
...estTemplateItem/portal_components/test.erp5.testIdTool.py
+3
-2
product/ERP5/Tool/IdTool.py
product/ERP5/Tool/IdTool.py
+5
-4
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testIdTool.py
View file @
86829ed4
...
@@ -34,6 +34,7 @@ import warnings
...
@@ -34,6 +34,7 @@ import warnings
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.Utils
import
unicode2str
from
MySQLdb
import
ProgrammingError
from
MySQLdb
import
ProgrammingError
from
six.moves
import
range
from
six.moves
import
range
...
@@ -195,7 +196,7 @@ class TestIdTool(ERP5TypeTestCase):
...
@@ -195,7 +196,7 @@ class TestIdTool(ERP5TypeTestCase):
ValueError
,
ValueError
,
self
.
id_tool
.
generateNewId
,
self
.
id_tool
.
generateNewId
,
id_generator
=
id_generator
,
id_generator
=
id_generator
,
id_group
=
u
'hé'
.
encode
(
'latin1'
),
id_group
=
u
nicode2str
(
u'hé'
,
'latin1'
),
)
)
def
test_02a_generateNewIdWithZODBGenerator
(
self
):
def
test_02a_generateNewIdWithZODBGenerator
(
self
):
...
@@ -335,7 +336,7 @@ class TestIdTool(ERP5TypeTestCase):
...
@@ -335,7 +336,7 @@ class TestIdTool(ERP5TypeTestCase):
ValueError
,
ValueError
,
self
.
id_tool
.
generateNewIdList
,
self
.
id_tool
.
generateNewIdList
,
id_generator
=
id_generator
,
id_generator
=
id_generator
,
id_group
=
u
'hé'
.
encode
(
'latin1'
),
id_group
=
u
nicode2str
(
u'hé'
,
'latin1'
),
id_count
=
1
,
id_count
=
1
,
)
)
...
...
product/ERP5/Tool/IdTool.py
View file @
86829ed4
...
@@ -36,6 +36,7 @@ from Products.ERP5Type.Globals import InitializeClass, DTMLFile, PersistentMappi
...
@@ -36,6 +36,7 @@ from Products.ERP5Type.Globals import InitializeClass, DTMLFile, PersistentMappi
from
Products.ERP5Type.Tool.BaseTool
import
BaseTool
from
Products.ERP5Type.Tool.BaseTool
import
BaseTool
from
Products.ERP5Type.Cache
import
caching_instance_method
from
Products.ERP5Type.Cache
import
caching_instance_method
from
Products.ERP5Type
import
Permissions
,
interfaces
from
Products.ERP5Type
import
Permissions
,
interfaces
from
Products.ERP5Type.Utils
import
str2unicode
,
bytes2str
from
zLOG
import
LOG
,
WARNING
,
INFO
,
ERROR
from
zLOG
import
LOG
,
WARNING
,
INFO
,
ERROR
from
Products.ERP5
import
_dtmldir
from
Products.ERP5
import
_dtmldir
...
@@ -120,14 +121,14 @@ class IdTool(BaseTool):
...
@@ -120,14 +121,14 @@ class IdTool(BaseTool):
# for compatibilty with sql data, must not use id_group as a list
# for compatibilty with sql data, must not use id_group as a list
if
six
.
PY3
and
isinstance
(
id_group
,
bytes
):
if
six
.
PY3
and
isinstance
(
id_group
,
bytes
):
warnings
.
warn
(
'id_group must be a string, not bytes.'
,
BytesWarning
)
warnings
.
warn
(
'id_group must be a string, not bytes.'
,
BytesWarning
)
id_group
=
id_group
.
decode
(
'utf-8'
)
id_group
=
bytes2str
(
id_group
)
if
not
isinstance
(
id_group
,
str
):
if
not
isinstance
(
id_group
,
str
):
id_group
=
repr
(
id_group
)
id_group
=
repr
(
id_group
)
warnings
.
warn
(
'id_group must be a string, other types '
warnings
.
warn
(
'id_group must be a string, other types '
'are deprecated.'
,
DeprecationWarning
)
'are deprecated.'
,
DeprecationWarning
)
if
six
.
PY2
:
if
six
.
PY2
:
try
:
try
:
id_group
.
decode
(
'utf-8'
)
str2unicode
(
id_group
)
except
UnicodeDecodeError
:
except
UnicodeDecodeError
:
raise
ValueError
(
raise
ValueError
(
'%r is not a valid id_group, only valid UTF-8 strings are allowed'
%
id_group
)
'%r is not a valid id_group, only valid UTF-8 strings are allowed'
%
id_group
)
...
@@ -188,7 +189,7 @@ class IdTool(BaseTool):
...
@@ -188,7 +189,7 @@ class IdTool(BaseTool):
raise
ValueError
(
'%r is not a valid id_group'
%
id_group
)
raise
ValueError
(
'%r is not a valid id_group'
%
id_group
)
if
six
.
PY3
and
isinstance
(
id_group
,
bytes
):
if
six
.
PY3
and
isinstance
(
id_group
,
bytes
):
warnings
.
warn
(
'id_group must be a string, not bytes.'
,
BytesWarning
)
warnings
.
warn
(
'id_group must be a string, not bytes.'
,
BytesWarning
)
id_group
=
id_group
.
decode
(
'utf-8'
)
id_group
=
bytes2str
(
id_group
)
# for compatibilty with sql data, must not use id_group as a list
# for compatibilty with sql data, must not use id_group as a list
if
not
isinstance
(
id_group
,
str
):
if
not
isinstance
(
id_group
,
str
):
id_group
=
repr
(
id_group
)
id_group
=
repr
(
id_group
)
...
@@ -196,7 +197,7 @@ class IdTool(BaseTool):
...
@@ -196,7 +197,7 @@ class IdTool(BaseTool):
'are deprecated.'
,
DeprecationWarning
)
'are deprecated.'
,
DeprecationWarning
)
if
six
.
PY2
:
if
six
.
PY2
:
try
:
try
:
id_group
.
decode
(
'utf-8'
)
str2unicode
(
id_group
)
except
UnicodeDecodeError
:
except
UnicodeDecodeError
:
raise
ValueError
(
raise
ValueError
(
'%r is not a valid id_group, only valid UTF-8 strings are allowed'
%
id_group
)
'%r is not a valid id_group, only valid UTF-8 strings are allowed'
%
id_group
)
...
...
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