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
139
Merge Requests
139
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
9ece5920
Commit
9ece5920
authored
Sep 15, 2022
by
Kazuhiko Shiozaki
Committed by
Jérome Perrin
Jul 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! py2/py3: Make Products code compatible with both python2 and python3.
parent
e82b8963
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
70 additions
and
48 deletions
+70
-48
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.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/ERP5Security/ERP5KeyAuthPlugin.py
product/ERP5Security/ERP5KeyAuthPlugin.py
+4
-3
product/ERP5Security/tests/testERP5Security.py
product/ERP5Security/tests/testERP5Security.py
+16
-12
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
+4
-5
product/ERP5Type/tests/ProcessingNodeTestCase.py
product/ERP5Type/tests/ProcessingNodeTestCase.py
+5
-2
product/ERP5Type/tests/utils.py
product/ERP5Type/tests/utils.py
+5
-1
product/ZSQLCatalog/Query/AutoQuery.py
product/ZSQLCatalog/Query/AutoQuery.py
+5
-5
product/ZSQLCatalog/SearchText/lexer.py
product/ZSQLCatalog/SearchText/lexer.py
+4
-1
product/ZSQLCatalog/tests/testSQLCatalog.py
product/ZSQLCatalog/tests/testSQLCatalog.py
+3
-1
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
9ece5920
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
import
six
import
six
from
six
import
string_types
as
basestring
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
import
fnmatch
,
gc
,
glob
,
imp
,
os
,
re
,
shutil
,
sys
,
time
,
tarfile
from
collections
import
defaultdict
from
collections
import
defaultdict
from
Shared.DC.ZRDB
import
Aqueduct
from
Shared.DC.ZRDB
import
Aqueduct
...
@@ -350,6 +350,8 @@ class BusinessTemplateArchive(object):
...
@@ -350,6 +350,8 @@ class BusinessTemplateArchive(object):
self
.
_writeString
(
obj
,
path
)
self
.
_writeString
(
obj
,
path
)
else
:
else
:
if
isinstance
(
obj
,
str
):
if
isinstance
(
obj
,
str
):
obj
=
str2bytes
(
obj
)
if
isinstance
(
obj
,
bytes
):
self
.
revision
.
hash
(
path
,
obj
)
self
.
revision
.
hash
(
path
,
obj
)
obj
=
BytesIO
(
obj
)
obj
=
BytesIO
(
obj
)
else
:
else
:
...
@@ -825,7 +827,7 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -825,7 +827,7 @@ class ObjectTemplateItem(BaseTemplateItem):
obj
=
obj
.
_getCopy
(
context
)
obj
=
obj
.
_getCopy
(
context
)
data
=
getattr
(
aq_base
(
obj
),
record_id
,
None
)
data
=
getattr
(
aq_base
(
obj
),
record_id
,
None
)
if
unicode_data
:
if
unicode_data
:
if
not
isinstance
(
data
,
six
.
text_type
):
if
not
(
six
.
PY2
and
isinstance
(
data
,
six
.
text_type
)
):
break
break
try
:
try
:
data
=
data
.
encode
(
aq_base
(
obj
).
output_encoding
)
data
=
data
.
encode
(
aq_base
(
obj
).
output_encoding
)
...
@@ -3523,7 +3525,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
...
@@ -3523,7 +3525,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
path
=
self
.
__class__
.
__name__
path
=
self
.
__class__
.
__name__
for
key
in
self
.
_objects
:
for
key
in
self
.
_objects
:
xml_data
=
self
.
generateXml
(
key
)
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'
)
xml_data
=
xml_data
.
encode
(
'utf-8'
)
name
=
key
.
split
(
'/'
,
1
)[
1
]
name
=
key
.
split
(
'/'
,
1
)[
1
]
bta
.
addObject
(
xml_data
,
name
=
name
,
path
=
path
)
bta
.
addObject
(
xml_data
,
name
=
name
,
path
=
path
)
...
@@ -3537,7 +3539,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
...
@@ -3537,7 +3539,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
xml_type_roles_list
=
xml
.
findall
(
'role'
)
xml_type_roles_list
=
xml
.
findall
(
'role'
)
for
role
in
xml_type_roles_list
:
for
role
in
xml_type_roles_list
:
id
=
role
.
get
(
'id'
)
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'
)
id
=
id
.
encode
(
'utf_8'
,
'backslashreplace'
)
type_role_property_dict
=
{
'id'
:
id
}
type_role_property_dict
=
{
'id'
:
id
}
# uniq
# uniq
...
@@ -3546,7 +3548,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
...
@@ -3546,7 +3548,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
property_id
=
property_node
.
get
(
'id'
)
property_id
=
property_node
.
get
(
'id'
)
if
property_node
.
text
:
if
property_node
.
text
:
value
=
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'
)
value
=
value
.
encode
(
'utf_8'
,
'backslashreplace'
)
type_role_property_dict
[
property_id
]
=
value
type_role_property_dict
[
property_id
]
=
value
# multi
# multi
...
@@ -3555,7 +3557,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
...
@@ -3555,7 +3557,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
property_id
=
property_node
.
get
(
'id'
)
property_id
=
property_node
.
get
(
'id'
)
if
property_node
.
text
:
if
property_node
.
text
:
value
=
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'
)
value
=
value
.
encode
(
'utf_8'
,
'backslashreplace'
)
type_role_property_dict
.
setdefault
(
property_id
,
[]).
append
(
value
)
type_role_property_dict
.
setdefault
(
property_id
,
[]).
append
(
value
)
type_roles_list
.
append
(
type_role_property_dict
)
type_roles_list
.
append
(
type_role_property_dict
)
...
@@ -4964,7 +4966,7 @@ class LocalRolesTemplateItem(BaseTemplateItem):
...
@@ -4964,7 +4966,7 @@ class LocalRolesTemplateItem(BaseTemplateItem):
xml_data
+=
'
\
n
</local_role_group_ids>'
xml_data
+=
'
\
n
</local_role_group_ids>'
xml_data
+=
'
\
n
</local_roles_item>'
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'
)
xml_data
=
xml_data
.
encode
(
'utf8'
)
return
xml_data
return
xml_data
...
...
product/ERP5/Tool/TemplateTool.py
View file @
9ece5920
...
@@ -1080,7 +1080,7 @@ class TemplateTool (BaseTool):
...
@@ -1080,7 +1080,7 @@ class TemplateTool (BaseTool):
installed_revision=installed_revision,
installed_revision=installed_revision,
repository=repository,
repository=repository,
**property_dict)
**property_dict)
obj.setUid(
uid
)
obj.setUid(
bytes2str(uid)
)
result_list.append(obj)
result_list.append(obj)
result_list.sort(key=lambda x: x.getTitle())
result_list.sort(key=lambda x: x.getTitle())
return result_list
return result_list
...
...
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.SimulableMixin.py
View file @
9ece5920
...
@@ -34,6 +34,7 @@ from Products.ERP5Type.Globals import InitializeClass
...
@@ -34,6 +34,7 @@ from Products.ERP5Type.Globals import InitializeClass
from
Products.ERP5Type.Base
import
Base
from
Products.ERP5Type.Base
import
Base
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.Errors
import
SimulationError
from
Products.ERP5Type.Errors
import
SimulationError
from
Products.ERP5Type.Utils
import
ensure_list
class
SimulableMixin
(
Base
):
class
SimulableMixin
(
Base
):
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
@@ -75,7 +76,7 @@ class SimulableMixin(Base):
...
@@ -75,7 +76,7 @@ class SimulableMixin(Base):
ignore
.
update
(
kw
)
ignore
.
update
(
kw
)
tv
[
ignore_key
]
=
ignore
tv
[
ignore_key
]
=
ignore
transaction
.
get
().
addBeforeCommitHook
(
before_commit
)
transaction
.
get
().
addBeforeCommitHook
(
before_commit
)
for
k
,
v
in
item_list
:
for
k
,
v
in
ensure_list
(
item_list
)
:
if
not
v
:
if
not
v
:
ignore
.
add
(
k
)
ignore
.
add
(
k
)
elif
k
not
in
ignore
:
elif
k
not
in
ignore
:
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_translateString.py
View file @
9ece5920
...
@@ -12,8 +12,10 @@ if translation_service is not None :
...
@@ -12,8 +12,10 @@ if translation_service is not None :
if
not
encoding
:
if
not
encoding
:
return
translation_service
.
translate
(
catalog
,
msg
,
lang
=
lang
,
**
kw
)
return
translation_service
.
translate
(
catalog
,
msg
,
lang
=
lang
,
**
kw
)
msg
=
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
)
msg
=
msg
.
encode
(
encoding
)
elif
six
.
PY3
and
isinstance
(
msg
,
six
.
binary_type
):
msg
=
msg
.
decode
(
encoding
)
return
msg
return
msg
except
AttributeError
:
# This happens in unit testing, because it is not able to find something with get_context()
except
AttributeError
:
# This happens in unit testing, because it is not able to find something with get_context()
pass
pass
...
...
product/ERP5Form/Tool/SelectionTool.py
View file @
9ece5920
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
"""
"""
from
OFS.SimpleItem
import
SimpleItem
from
OFS.SimpleItem
import
SimpleItem
from
Products.ERP5Type.Utils
import
ensure_list
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
,
PersistentMapping
,
get_request
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
,
PersistentMapping
,
get_request
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
ZTUtils
import
make_query
from
ZTUtils
import
make_query
...
@@ -434,7 +435,7 @@ class SelectionTool( BaseTool, SimpleItem ):
...
@@ -434,7 +435,7 @@ class SelectionTool( BaseTool, SimpleItem ):
selection_uid_dict
[
int
(
uid
)]
=
1
selection_uid_dict
[
int
(
uid
)]
=
1
except
(
ValueError
,
TypeError
):
except
(
ValueError
,
TypeError
):
selection_uid_dict
[
uid
]
=
1
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
:
if
REQUEST
is
not
None
:
return
self
.
_redirectToOriginalForm
(
REQUEST
=
REQUEST
,
form_id
=
form_id
,
return
self
.
_redirectToOriginalForm
(
REQUEST
=
REQUEST
,
form_id
=
form_id
,
query_string
=
query_string
,
no_reset
=
True
)
query_string
=
query_string
,
no_reset
=
True
)
...
...
product/ERP5Security/ERP5KeyAuthPlugin.py
View file @
9ece5920
...
@@ -46,6 +46,7 @@ from Products.PluggableAuthService.plugins.CookieAuthHelper import CookieAuthHel
...
@@ -46,6 +46,7 @@ from Products.PluggableAuthService.plugins.CookieAuthHelper import CookieAuthHel
from
Products.ERP5Type.Cache
import
CachingMethod
from
Products.ERP5Type.Cache
import
CachingMethod
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
from
Products.ERP5Type.Utils
import
bytes2str
from
Products.ERP5Security.ERP5UserManager
import
ERP5UserManager
,
\
from
Products.ERP5Security.ERP5UserManager
import
ERP5UserManager
,
\
_AuthenticationFailure
_AuthenticationFailure
from
Products
import
ERP5Security
from
Products
import
ERP5Security
...
@@ -64,7 +65,7 @@ class AESCipher:
...
@@ -64,7 +65,7 @@ class AESCipher:
def
encrypt
(
self
,
login
):
def
encrypt
(
self
,
login
):
iv
=
Random
.
new
().
read
(
AES
.
block_size
)
iv
=
Random
.
new
().
read
(
AES
.
block_size
)
encryptor
=
AES
.
new
(
self
.
encryption_key
,
self
.
mode
,
IV
=
iv
)
encryptor
=
AES
.
new
(
self
.
encryption_key
,
self
.
mode
,
IV
=
iv
)
return
urlsafe_b64encode
(
iv
+
encryptor
.
encrypt
(
login
.
ljust
(((
len
(
login
)
-
1
)
/
16
+
1
)
*
16
)))
return
urlsafe_b64encode
(
iv
+
encryptor
.
encrypt
(
login
.
ljust
(((
len
(
login
)
-
1
)
/
/
16
+
1
)
*
16
)))
def
decrypt
(
self
,
crypted_login
):
def
decrypt
(
self
,
crypted_login
):
decoded_crypted_login
=
urlsafe_b64decode
(
crypted_login
)
decoded_crypted_login
=
urlsafe_b64decode
(
crypted_login
)
...
@@ -217,13 +218,13 @@ class ERP5KeyAuthPlugin(ERP5UserManager, CookieAuthHelper):
...
@@ -217,13 +218,13 @@ class ERP5KeyAuthPlugin(ERP5UserManager, CookieAuthHelper):
def
encrypt
(
self
,
login
):
def
encrypt
(
self
,
login
):
"""Encrypt the login"""
"""Encrypt the login"""
cipher
=
globals
()[
'%sCipher'
%
self
.
_getCipher
()](
self
.
encryption_key
)
cipher
=
globals
()[
'%sCipher'
%
self
.
_getCipher
()](
self
.
encryption_key
)
return
cipher
.
encrypt
(
login
)
return
bytes2str
(
cipher
.
encrypt
(
login
)
)
security
.
declarePrivate
(
'decrypt'
)
security
.
declarePrivate
(
'decrypt'
)
def
decrypt
(
self
,
crypted_login
):
def
decrypt
(
self
,
crypted_login
):
"""Decrypt string and return the login"""
"""Decrypt string and return the login"""
cipher
=
globals
()[
'%sCipher'
%
self
.
_getCipher
()](
self
.
encryption_key
)
cipher
=
globals
()[
'%sCipher'
%
self
.
_getCipher
()](
self
.
encryption_key
)
return
cipher
.
decrypt
(
crypted_login
)
return
bytes2str
(
cipher
.
decrypt
(
crypted_login
)
)
####################################
####################################
#ILoginPasswordHostExtractionPlugin#
#ILoginPasswordHostExtractionPlugin#
...
...
product/ERP5Security/tests/testERP5Security.py
View file @
9ece5920
...
@@ -34,9 +34,11 @@ import mock
...
@@ -34,9 +34,11 @@ import mock
import
itertools
import
itertools
import
transaction
import
transaction
import
unittest
import
unittest
import
urlparse
import
six
from
six.moves.urllib.parse
import
urlparse
,
parse_qs
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
bytes2str
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
getSecurityManager
from
AccessControl.SecurityManagement
import
getSecurityManager
from
AccessControl
import
SpecialUsers
from
AccessControl
import
SpecialUsers
...
@@ -57,8 +59,10 @@ class UserManagementTestCase(ERP5TypeTestCase):
...
@@ -57,8 +59,10 @@ class UserManagementTestCase(ERP5TypeTestCase):
"""TestCase for user manement, with utilities to create users and helpers
"""TestCase for user manement, with utilities to create users and helpers
assertion methods.
assertion methods.
"""
"""
if
six
.
PY2
:
_login_generator
=
itertools
.
count
().
next
_login_generator
=
itertools
.
count
().
next
else
:
_login_generator
=
itertools
.
count
().
__next__
def
getBusinessTemplateList
(
self
):
def
getBusinessTemplateList
(
self
):
"""List of BT to install. """
"""List of BT to install. """
...
@@ -719,12 +723,12 @@ class TestPreferences(UserManagementTestCase):
...
@@ -719,12 +723,12 @@ class TestPreferences(UserManagementTestCase):
current_password
=
'bad'
+
password
,
current_password
=
'bad'
+
password
,
new_password
=
new_password
,
new_password
=
new_password
,
)
)
parsed_url
=
urlparse
.
urlparse
(
result
)
parsed_url
=
urlparse
(
result
)
self
.
assertEqual
(
self
.
assertEqual
(
parsed_url
.
path
.
split
(
'/'
)[
-
2
:],
parsed_url
.
path
.
split
(
'/'
)[
-
2
:],
[
'portal_preferences'
,
'PreferenceTool_viewChangePasswordDialog'
])
[
'portal_preferences'
,
'PreferenceTool_viewChangePasswordDialog'
])
self
.
assertEqual
(
self
.
assertEqual
(
urlparse
.
parse_qs
(
parsed_url
.
query
),
parse_qs
(
parsed_url
.
query
),
{
'portal_status_message'
:
[
'Current password is wrong.'
],
'portal_status_level'
:
[
'error'
]})
{
'portal_status_message'
:
[
'Current password is wrong.'
],
'portal_status_level'
:
[
'error'
]})
self
.
login
()
self
.
login
()
...
@@ -1179,8 +1183,8 @@ class TestUserManagementExternalAuthentication(TestUserManagement):
...
@@ -1179,8 +1183,8 @@ class TestUserManagementExternalAuthentication(TestUserManagement):
# view front page we should be logged in if we use authentication key
# view front page we should be logged in if we use authentication key
response
=
self
.
publish
(
base_url
,
env
=
{
self
.
user_id_key
.
replace
(
'-'
,
'_'
).
upper
():
login
})
response
=
self
.
publish
(
base_url
,
env
=
{
self
.
user_id_key
.
replace
(
'-'
,
'_'
).
upper
():
login
})
self
.
assertEqual
(
response
.
getStatus
(),
200
)
self
.
assertEqual
(
response
.
getStatus
(),
200
)
self
.
assertIn
(
'Logged In'
,
response
.
getBody
(
))
self
.
assertIn
(
'Logged In'
,
bytes2str
(
response
.
getBody
()
))
self
.
assertIn
(
login
,
response
.
getBody
(
))
self
.
assertIn
(
login
,
bytes2str
(
response
.
getBody
()
))
class
TestLocalRoleManagement
(
RoleManagementTestCase
):
class
TestLocalRoleManagement
(
RoleManagementTestCase
):
...
@@ -1271,7 +1275,7 @@ class TestLocalRoleManagement(RoleManagementTestCase):
...
@@ -1271,7 +1275,7 @@ class TestLocalRoleManagement(RoleManagementTestCase):
# check if assignment change is effective immediately
# check if assignment change is effective immediately
self
.
login
()
self
.
login
()
res
=
viewSecurity
()
res
=
viewSecurity
()
self
.
assertEqual
([
x
for
x
in
res
.
body
.
splitlines
()
if
x
.
startswith
(
'-->'
)],
self
.
assertEqual
([
x
for
x
in
bytes2str
(
res
.
body
)
.
splitlines
()
if
x
.
startswith
(
'-->'
)],
[
"--> ['F1_G1_S1']"
],
res
.
body
)
[
"--> ['F1_G1_S1']"
],
res
.
body
)
assignment
=
self
.
person
.
newContent
(
portal_type
=
'Assignment'
,
assignment
=
self
.
person
.
newContent
(
portal_type
=
'Assignment'
,
group
=
'subcat'
,
group
=
'subcat'
,
...
@@ -1279,11 +1283,11 @@ class TestLocalRoleManagement(RoleManagementTestCase):
...
@@ -1279,11 +1283,11 @@ class TestLocalRoleManagement(RoleManagementTestCase):
function
=
'another_subcat'
)
function
=
'another_subcat'
)
assignment
.
open
()
assignment
.
open
()
res
=
viewSecurity
()
res
=
viewSecurity
()
self
.
assertEqual
([
x
for
x
in
res
.
body
.
splitlines
()
if
x
.
startswith
(
'-->'
)],
self
.
assertEqual
([
x
for
x
in
bytes2str
(
res
.
body
)
.
splitlines
()
if
x
.
startswith
(
'-->'
)],
[
"--> ['F1_G1_S1']"
,
"--> ['F2_G1_S1']"
],
res
.
body
)
[
"--> ['F1_G1_S1']"
,
"--> ['F2_G1_S1']"
],
res
.
body
)
assignment
.
setGroup
(
'another_subcat'
)
assignment
.
setGroup
(
'another_subcat'
)
res
=
viewSecurity
()
res
=
viewSecurity
()
self
.
assertEqual
([
x
for
x
in
res
.
body
.
splitlines
()
if
x
.
startswith
(
'-->'
)],
self
.
assertEqual
([
x
for
x
in
bytes2str
(
res
.
body
)
.
splitlines
()
if
x
.
startswith
(
'-->'
)],
[
"--> ['F1_G1_S1']"
,
"--> ['F2_G2_S1']"
],
res
.
body
)
[
"--> ['F1_G1_S1']"
,
"--> ['F2_G2_S1']"
],
res
.
body
)
self
.
abort
()
self
.
abort
()
...
@@ -1499,7 +1503,7 @@ class TestKeyAuthentication(RoleManagementTestCase):
...
@@ -1499,7 +1503,7 @@ class TestKeyAuthentication(RoleManagementTestCase):
# view front page we should be logged in if we use authentication key
# view front page we should be logged in if we use authentication key
response
=
self
.
publish
(
'%s?__ac_key=%s'
%
(
base_url
,
key
))
response
=
self
.
publish
(
'%s?__ac_key=%s'
%
(
base_url
,
key
))
self
.
assertEqual
(
response
.
getStatus
(),
200
)
self
.
assertEqual
(
response
.
getStatus
(),
200
)
self
.
assertIn
(
reference
,
response
.
getBody
(
))
self
.
assertIn
(
reference
,
bytes2str
(
response
.
getBody
()
))
# check if key authentication works other page than front page
# check if key authentication works other page than front page
person_module
=
portal
.
person_module
person_module
=
portal
.
person_module
...
@@ -1510,7 +1514,7 @@ class TestKeyAuthentication(RoleManagementTestCase):
...
@@ -1510,7 +1514,7 @@ class TestKeyAuthentication(RoleManagementTestCase):
self
.
assertTrue
(
'%s/login_form?came_from='
%
portal
.
getId
(),
response
.
headers
[
'location'
])
self
.
assertTrue
(
'%s/login_form?came_from='
%
portal
.
getId
(),
response
.
headers
[
'location'
])
response
=
self
.
publish
(
'%s?__ac_key=%s'
%
(
base_url
,
key
))
response
=
self
.
publish
(
'%s?__ac_key=%s'
%
(
base_url
,
key
))
self
.
assertEqual
(
response
.
getStatus
(),
200
)
self
.
assertEqual
(
response
.
getStatus
(),
200
)
self
.
assertIn
(
reference
,
response
.
getBody
(
))
self
.
assertIn
(
reference
,
bytes2str
(
response
.
getBody
()
))
# check if key authentication works with web_mode too
# check if key authentication works with web_mode too
web_site
=
portal
.
web_site_module
.
newContent
(
portal_type
=
'Web Site'
)
web_site
=
portal
.
web_site_module
.
newContent
(
portal_type
=
'Web Site'
)
...
...
product/ERP5Type/Message.py
View file @
9ece5920
...
@@ -112,7 +112,7 @@ class Message(Persistent):
...
@@ -112,7 +112,7 @@ class Message(Persistent):
if
self
.
domain
is
None
:
if
self
.
domain
is
None
:
# Map the translated string with given parameters
# Map the translated string with given parameters
if
type
(
self
.
mapping
)
is
dict
:
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
=
message
.
encode
(
'utf-8'
)
message
=
Template
(
message
).
substitute
(
self
.
mapping
)
message
=
Template
(
message
).
substitute
(
self
.
mapping
)
else
:
else
:
...
@@ -122,7 +122,7 @@ class Message(Persistent):
...
@@ -122,7 +122,7 @@ class Message(Persistent):
if
self
.
mapping
:
if
self
.
mapping
:
unicode_mapping
=
{}
unicode_mapping
=
{}
for
k
,
v
in
six
.
iteritems
(
self
.
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'
)
v
=
v
.
decode
(
'utf-8'
)
unicode_mapping
[
k
]
=
v
unicode_mapping
[
k
]
=
v
else
:
else
:
...
@@ -137,9 +137,9 @@ class Message(Persistent):
...
@@ -137,9 +137,9 @@ class Message(Persistent):
message
=
translated_message
message
=
translated_message
if
isinstance
(
self
.
message
,
str
):
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'
)
message
=
message
.
encode
(
'utf-8'
)
elif
isinstance
(
message
,
str
):
elif
six
.
PY2
and
isinstance
(
message
,
str
):
message
=
message
.
decode
(
'utf-8'
)
message
=
message
.
decode
(
'utf-8'
)
return
message
return
message
...
@@ -152,7 +152,7 @@ class Message(Persistent):
...
@@ -152,7 +152,7 @@ class Message(Persistent):
Return the translated message as a string object.
Return the translated message as a string object.
"""
"""
message
=
self
.
translate
()
message
=
self
.
translate
()
if
isinstance
(
message
,
six
.
text_type
):
if
six
.
PY2
and
isinstance
(
message
,
six
.
text_type
):
message
=
message
.
encode
(
'utf-8'
)
message
=
message
.
encode
(
'utf-8'
)
return
message
return
message
...
@@ -161,7 +161,7 @@ class Message(Persistent):
...
@@ -161,7 +161,7 @@ class Message(Persistent):
Return the translated message as a unicode object.
Return the translated message as a unicode object.
"""
"""
message
=
self
.
translate
()
message
=
self
.
translate
()
if
isinstance
(
message
,
str
):
if
six
.
PY2
and
isinstance
(
message
,
str
):
message
=
message
.
decode
(
'utf-8'
)
message
=
message
.
decode
(
'utf-8'
)
return
message
return
message
...
...
product/ERP5Type/patches/DA.py
View file @
9ece5920
...
@@ -219,7 +219,7 @@ def DA__call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw):
...
@@ -219,7 +219,7 @@ def DA__call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw):
if
src__
:
return
query
if
src__
:
return
query
if
self
.
cache_time_
>
0
and
self
.
max_cache_
>
0
:
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
:
else
:
try
:
try
:
result
=
DB__
.
query
(
query
,
self
.
max_rows_
)
result
=
DB__
.
query
(
query
,
self
.
max_rows_
)
...
...
product/ERP5Type/tests/ERP5TypeTestCase.py
View file @
9ece5920
...
@@ -9,7 +9,7 @@ __version__ = '0.3.0'
...
@@ -9,7 +9,7 @@ __version__ = '0.3.0'
import
base64
import
base64
import
errno
import
errno
import
httplib
from
six.moves
import
http_client
import
os
import
os
import
random
import
random
import
re
import
re
...
@@ -19,12 +19,12 @@ import sys
...
@@ -19,12 +19,12 @@ import sys
import
time
import
time
import
traceback
import
traceback
import
urllib
import
urllib
import
ConfigP
arser
from
six.moves
import
configp
arser
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
io
import
BytesIO
from
io
import
BytesIO
from
functools
import
partial
from
functools
import
partial
from
six.moves.urllib.parse
import
unquote_to_bytes
from
six.moves.urllib.parse
import
unquote_to_bytes
from
cPickle
import
dumps
from
six.moves.
cPickle
import
dumps
from
glob
import
glob
from
glob
import
glob
from
hashlib
import
md5
from
hashlib
import
md5
from
warnings
import
warn
from
warnings
import
warn
...
@@ -32,7 +32,6 @@ from DateTime import DateTime
...
@@ -32,7 +32,6 @@ from DateTime import DateTime
import
mock
import
mock
import
Products.ZMySQLDA.DA
import
Products.ZMySQLDA.DA
from
Products.ZMySQLDA.DA
import
Connection
as
ZMySQLDA_Connection
from
Products.ZMySQLDA.DA
import
Connection
as
ZMySQLDA_Connection
from
zope.globalrequest
import
clearRequest
from
zope.globalrequest
import
getRequest
from
zope.globalrequest
import
getRequest
from
zope.globalrequest
import
setRequest
from
zope.globalrequest
import
setRequest
import
six
import
six
...
@@ -154,7 +153,7 @@ def _createTestPromiseConfigurationFile(promise_path, bt5_repository_path_list=N
...
@@ -154,7 +153,7 @@ def _createTestPromiseConfigurationFile(promise_path, bt5_repository_path_list=N
_getVolatileMemcachedServerDict
()
_getVolatileMemcachedServerDict
()
cloudooo_url_list
=
_getConversionServerUrlList
()
cloudooo_url_list
=
_getConversionServerUrlList
()
promise_config
=
ConfigP
arser
.
RawConfigParser
()
promise_config
=
configp
arser
.
RawConfigParser
()
promise_config
.
add_section
(
'external_service'
)
promise_config
.
add_section
(
'external_service'
)
promise_config
.
set
(
'external_service'
,
'cloudooo_url_list'
,
cloudooo_url_list
)
promise_config
.
set
(
'external_service'
,
'cloudooo_url_list'
,
cloudooo_url_list
)
promise_config
.
set
(
'external_service'
,
'memcached_url'
,
memcached_url
)
promise_config
.
set
(
'external_service'
,
'memcached_url'
,
memcached_url
)
...
...
product/ERP5Type/tests/ProcessingNodeTestCase.py
View file @
9ece5920
...
@@ -2,7 +2,10 @@
...
@@ -2,7 +2,10 @@
import
errno
,
logging
,
mock
,
os
,
socket
,
time
import
errno
,
logging
,
mock
,
os
,
socket
,
time
import
itertools
import
itertools
from
threading
import
Thread
from
threading
import
Thread
from
UserDict
import
IterableUserDict
try
:
# six.PY2
from
UserDict
import
IterableUserDict
as
UserDict
except
ImportError
:
from
collections
import
UserDict
import
transaction
import
transaction
from
Testing
import
ZopeTestCase
from
Testing
import
ZopeTestCase
from
zope.globalrequest
import
setRequest
from
zope.globalrequest
import
setRequest
...
@@ -15,7 +18,7 @@ from Products.ERP5Type.tests.utils import \
...
@@ -15,7 +18,7 @@ from Products.ERP5Type.tests.utils import \
from
Products.CMFActivity.ActivityTool
import
getCurrentNode
from
Products.CMFActivity.ActivityTool
import
getCurrentNode
class
DictPersistentWrapper
(
Iterable
UserDict
,
object
):
class
DictPersistentWrapper
(
UserDict
,
object
):
def
__metaclass__
(
name
,
base
,
d
):
def
__metaclass__
(
name
,
base
,
d
):
def
wrap
(
attr
):
def
wrap
(
attr
):
...
...
product/ERP5Type/tests/utils.py
View file @
9ece5920
...
@@ -55,8 +55,12 @@ from Products.ERP5Type.Utils import simple_decorator
...
@@ -55,8 +55,12 @@ from Products.ERP5Type.Utils import simple_decorator
from
Products.ZSQLCatalog.SQLCatalog
import
Catalog
from
Products.ZSQLCatalog.SQLCatalog
import
Catalog
import
pytz
import
pytz
import
six
import
six
if
six
.
PY2
:
FileIO
=
file
else
:
from
io
import
FileIO
class
FileUpload
(
file
):
class
FileUpload
(
FileIO
):
"""Act as an uploaded file.
"""Act as an uploaded file.
"""
"""
__allow_access_to_unprotected_subobjects__
=
1
__allow_access_to_unprotected_subobjects__
=
1
...
...
product/ZSQLCatalog/Query/AutoQuery.py
View file @
9ece5920
...
@@ -76,17 +76,17 @@ class AutoQuery(Query):
...
@@ -76,17 +76,17 @@ class AutoQuery(Query):
# Recreate value as a dict and pass it to buildSingleQuery.
# Recreate value as a dict and pass it to buildSingleQuery.
range
=
kw
.
pop
(
'range'
)
range
=
kw
.
pop
(
'range'
)
assert
len
(
kw
)
==
1
,
repr
(
kw
)
assert
len
(
kw
)
==
1
,
repr
(
kw
)
key
,
value
=
kw
.
items
(
)[
0
]
key
,
value
=
list
(
kw
.
items
()
)[
0
]
query
=
sql_catalog
.
buildSingleQuery
(
key
,
{
'query'
:
value
,
query
=
sql_catalog
.
buildSingleQuery
(
key
,
{
'query'
:
value
,
'range'
:
range
})
'range'
:
range
})
elif
operator
==
'in'
:
elif
operator
==
'in'
:
# 'in' is a *comparison* operator, not a logical operator.
# 'in' is a *comparison* operator, not a logical operator.
# Transform kw into the proper form.
# Transform kw into the proper form.
assert
len
(
kw
)
==
1
,
repr
(
kw
)
assert
len
(
kw
)
==
1
,
repr
(
kw
)
key
,
value
=
kw
.
items
(
)[
0
]
key
,
value
=
list
(
kw
.
items
()
)[
0
]
query
=
sql_catalog
.
buildSingleQuery
(
key
,
{
'query'
:
value
,
query
=
sql_catalog
.
buildSingleQuery
(
key
,
{
'query'
:
value
,
'operator'
:
operator
})
'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'
):
operator
in
(
'and'
,
'or'
):
# If there is only one parameter, and operator was given and is a
# If there is only one parameter, and operator was given and is a
# known logical operator, then operator will apply to it.
# known logical operator, then operator will apply to it.
...
@@ -94,7 +94,7 @@ class AutoQuery(Query):
...
@@ -94,7 +94,7 @@ class AutoQuery(Query):
# kw = {'portal_type': ['!=a', '!=b'], 'operator': 'AND'}
# kw = {'portal_type': ['!=a', '!=b'], 'operator': 'AND'}
# In such case, expected result is
# In such case, expected result is
# "portal_type!='a' AND portal_type!='b'"
# "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
)
query
=
sql_catalog
.
buildSingleQuery
(
key
,
value
,
logical_operator
=
operator
)
else
:
else
:
# Otherwise, the operator will apply to the relationship between
# Otherwise, the operator will apply to the relationship between
...
@@ -102,7 +102,7 @@ class AutoQuery(Query):
...
@@ -102,7 +102,7 @@ class AutoQuery(Query):
if
operator
is
None
:
if
operator
is
None
:
operator
=
'and'
operator
=
'and'
if
self
.
search_key
is
not
None
:
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
}}
kw
=
{
key
:
{
'query'
:
value
,
'key'
:
self
.
search_key
}}
query
=
sql_catalog
.
buildQuery
(
kw
,
operator
=
operator
,
ignore_empty_string
=
self
.
ignore_empty_string
)
query
=
sql_catalog
.
buildQuery
(
kw
,
operator
=
operator
,
ignore_empty_string
=
self
.
ignore_empty_string
)
if
self
.
table_alias_list
is
not
None
:
if
self
.
table_alias_list
is
not
None
:
...
...
product/ZSQLCatalog/SearchText/lexer.py
View file @
9ece5920
...
@@ -58,7 +58,10 @@ class lexer(object):
...
@@ -58,7 +58,10 @@ class lexer(object):
write_tables
=
False
)
write_tables
=
False
)
sys
.
stdout
,
sys
.
stderr
=
sys
.
__stdout__
,
sys
.
__stderr__
sys
.
stdout
,
sys
.
stderr
=
sys
.
__stdout__
,
sys
.
__stderr__
# Emit all logs with regular Zope logging
# 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
):
if
len
(
line
):
LOG
(
'lexer'
,
0
,
line
)
LOG
(
'lexer'
,
0
,
line
)
...
...
product/ZSQLCatalog/tests/testSQLCatalog.py
View file @
9ece5920
...
@@ -39,7 +39,9 @@ from Products.ZSQLCatalog.Query.RelatedQuery import RelatedQuery
...
@@ -39,7 +39,9 @@ from Products.ZSQLCatalog.Query.RelatedQuery import RelatedQuery
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
Products.ZSQLCatalog.SQLExpression
import
MergeConflictError
from
Products.ZSQLCatalog.SQLExpression
import
MergeConflictError
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.Utils
import
ensure_list
import
six
import
six
from
six.moves
import
xrange
class
MatchList
(
list
):
class
MatchList
(
list
):
def
__repr__
(
self
):
def
__repr__
(
self
):
...
@@ -99,7 +101,7 @@ class ReferenceQuery:
...
@@ -99,7 +101,7 @@ class ReferenceQuery:
else
:
else
:
self
.
args
.
append
(
arg
)
self
.
args
.
append
(
arg
)
if
len
(
kw
)
==
1
:
if
len
(
kw
)
==
1
:
self
.
column
,
value
=
kw
.
items
(
)[
0
]
self
.
column
,
value
=
ensure_list
(
kw
.
items
()
)[
0
]
if
not
isinstance
(
value
,
MatchList
):
if
not
isinstance
(
value
,
MatchList
):
value
=
MatchList
([
value
])
value
=
MatchList
([
value
])
self
.
value
=
value
self
.
value
=
value
...
...
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