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
Carlos Ramos Carreño
erp5
Commits
3d76c463
Commit
3d76c463
authored
Apr 20, 2022
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py3: No more unbound methods in python3.
parent
063bb8a1
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
20 deletions
+64
-20
product/CMFActivity/tests/testCMFActivity.py
product/CMFActivity/tests/testCMFActivity.py
+16
-5
product/ERP5/ERP5Site.py
product/ERP5/ERP5Site.py
+5
-1
product/ERP5/Interaction.py
product/ERP5/Interaction.py
+5
-1
product/ERP5/InteractionWorkflow.py
product/ERP5/InteractionWorkflow.py
+5
-3
product/ERP5/mixin/timer_service.py
product/ERP5/mixin/timer_service.py
+14
-6
product/ERP5Type/dynamic/persistent_migration.py
product/ERP5Type/dynamic/persistent_migration.py
+7
-1
product/ERP5Type/patches/ExternalMethod.py
product/ERP5Type/patches/ExternalMethod.py
+4
-1
product/ERP5Type/tests/backportUnittest.py
product/ERP5Type/tests/backportUnittest.py
+8
-2
No files found.
product/CMFActivity/tests/testCMFActivity.py
View file @
3d76c463
...
...
@@ -1883,7 +1883,10 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
Speed up test by not interrupting the first transaction
as soon as we have the information we want.
"""
original_query
=
DB
.
query
.
__func__
original_query
=
DB
.
query
import
six
if
six
.
PY2
:
original_query
=
original_query
.
__func__
def
query
(
self
,
query_string
,
*
args
,
**
kw
):
if
query_string
.
startswith
(
'INSERT'
):
insert_list
.
append
(
len
(
query_string
))
...
...
@@ -2054,7 +2057,10 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
def
testTryNotificationSavedOnEventLogWhenNotifyUserRaises
(
self
,
activity
):
obj
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
)
self
.
tic
()
original_notifyUser
=
Message
.
notifyUser
.
im_func
original_notifyUser
=
Message
.
notifyUser
import
six
if
six
.
PY2
:
original_notifyUser
=
original_notifyUser
.
__func__
def
failSendingEmail
(
self
,
*
args
,
**
kw
):
raise
MailHostError
(
'Mail is not sent'
)
activity_unit_test_error
=
Exception
()
...
...
@@ -2084,7 +2090,10 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
def
testNotificationFailureIsNotSavedOnEventLogWhenMailNotificationIsDisabled
(
self
,
activity
):
obj
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
)
self
.
tic
()
original_notifyUser
=
Message
.
notifyUser
.
im_func
original_notifyUser
=
Message
.
notifyUser
import
six
if
six
.
PY2
:
original_notifyUser
=
original_notifyUser
.
__func__
def
failSendingEmail
(
self
,
*
args
,
**
kw
):
raise
MailHostError
(
'Mail is not sent'
)
activity_unit_test_error
=
Exception
()
...
...
@@ -2152,8 +2161,10 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
def
failingMethod
(
self
):
raise
activity_unit_test_error
from
Products.SiteErrorLog.SiteErrorLog
import
SiteErrorLog
original_raising
=
SiteErrorLog
.
raising
.
im_func
original_raising
=
SiteErrorLog
.
raising
import
six
if
six
.
PY2
:
original_raising
=
original_raising
.
__func__
# Monkey patch Site Error to induce conflict errors artificially.
def
raising
(
self
,
info
):
raise
AttributeError
...
...
product/ERP5/ERP5Site.py
View file @
3d76c463
...
...
@@ -19,6 +19,7 @@ from __future__ import absolute_import
from
DateTime
import
DateTime
from
six.moves
import
map
import
thread
,
threading
import
six
from
weakref
import
ref
as
weakref
from
OFS.Application
import
Application
,
AppInitializer
from
Products.ERP5Type
import
Globals
...
...
@@ -2437,7 +2438,10 @@ class ERP5Generator(PortalGenerator):
# Zope offers no mechanism to extend AppInitializer so let's monkey-patch.
AppInitializer_initialize
=
AppInitializer
.
initialize
.
__func__
AppInitializer_initialize
=
AppInitializer
.
initialize
if
six
.
PY2
:
# No more unbound methods in py3
AppInitializer_initialize
=
AppInitializer_initialize
.
__func__
def
initialize
(
self
):
AppInitializer
.
initialize
=
AppInitializer_initialize
self
.
initialize
()
...
...
product/ERP5/Interaction.py
View file @
3d76c463
...
...
@@ -304,7 +304,11 @@ class InteractionDefinition (SimpleItem):
def
checkGuard
(
self
,
*
args
,
**
kwargs
):
from
Products.ERP5Type.mixin.guardable
import
GuardableMixin
return
GuardableMixin
.
checkGuard
.
im_func
(
self
,
*
args
,
**
kwargs
)
checkGuard
=
GuardableMixin
.
checkGuard
import
six
if
six
.
PY2
:
checkGuard
=
checkGuard
.
__func__
return
checkGuard
(
self
,
*
args
,
**
kwargs
)
def
getPortalTypeGroupFilterList
(
self
):
if
self
.
portal_type_group_filter
is
None
:
...
...
product/ERP5/InteractionWorkflow.py
View file @
3d76c463
...
...
@@ -391,8 +391,10 @@ for method_name, security in (
):
if
security
is
not
None
:
security
(
method_name
)
setattr
(
InteractionWorkflowDefinition
,
method_name
,
getattr
(
ERP5InteractionWorkflow
,
method_name
).
im_func
)
func
=
getattr
(
ERP5InteractionWorkflow
,
method_name
)
import
six
if
six
.
PY2
:
func
=
func
.
__func__
setattr
(
InteractionWorkflowDefinition
,
method_name
,
func
)
Globals
.
InitializeClass
(
InteractionWorkflowDefinition
)
product/ERP5/mixin/timer_service.py
View file @
3d76c463
...
...
@@ -26,7 +26,7 @@
#
##############################################################################
import
warnings
import
warnings
,
six
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.CMFActivity.ActivityTool
import
ActivityTool
...
...
@@ -79,11 +79,19 @@ class TimerServiceMixin(object):
self
.
subscribe
()
super
(
TimerServiceMixin
,
self
).
manage_afterAdd
(
*
args
,
**
kw
)
if
six
.
PY2
:
security
.
declarePublic
(
'getCurrentNode'
)
getCurrentNode
=
ActivityTool
.
getCurrentNode
.
im_func
getCurrentNode
=
ActivityTool
.
getCurrentNode
.
__func__
security
.
declarePublic
(
'getServerAddress'
)
getServerAddress
=
ActivityTool
.
getServerAddress
.
im_func
getServerAddress
=
ActivityTool
.
getServerAddress
.
__func__
_isValidNodeName
=
ActivityTool
.
_isValidNodeName
.
__func__
else
:
# no more unbound in py3, we got the function directly
security
.
declarePublic
(
'getCurrentNode'
)
getCurrentNode
=
ActivityTool
.
getCurrentNode
security
.
declarePublic
(
'getServerAddress'
)
getServerAddress
=
ActivityTool
.
getServerAddress
_isValidNodeName
=
ActivityTool
.
_isValidNodeName
_isValidNodeName
=
ActivityTool
.
_isValidNodeName
.
im_func
InitializeClass
(
TimerServiceMixin
)
product/ERP5Type/dynamic/persistent_migration.py
View file @
3d76c463
...
...
@@ -96,7 +96,13 @@ class PickleUpdater(ObjectReader, ObjectWriter, object):
if
_setOb
:
if
isinstance
(
_setOb
,
WorkflowMethod
):
_setOb
=
_setOb
.
_m
if
_setOb
.
im_func
is
OFS_Folder
.
_setOb
.
im_func
:
import
six
setOb_func
=
_setOb
OFS_Folder_setOb_func
=
OFS_Folder
.
_setOb
if
six
.
PY2
:
setOb_func
=
setOb_func
.
__func__
OFS_Folder_setOb_func
=
OFS_Folder_setOb_func
.
__func__
if
setOb_func
is
OFS_Folder_setOb_func
:
self
.
lazy
=
Ghost
elif
klass
.
__module__
[:
7
]
==
'BTrees.'
and
klass
.
__name__
!=
'Length'
:
self
.
lazy
=
LazyBTree
()
...
...
product/ERP5Type/patches/ExternalMethod.py
View file @
3d76c463
...
...
@@ -88,7 +88,10 @@ class _(PatchClass(ExternalMethod)):
arg_list
.
append
(
'**'
+
argument_object
.
keywords
)
i
=
isinstance
(
f
,
MethodType
)
ff
=
f
.
__func__
if
i
else
f
ff
=
f
import
six
if
six
.
PY2
and
i
:
ff
=
f
.
__func__
has_self
=
len
(
arg_list
)
>
i
and
arg_list
[
i
]
==
'self'
i
+=
has_self
if
i
:
...
...
product/ERP5Type/tests/backportUnittest.py
View file @
3d76c463
...
...
@@ -12,7 +12,10 @@ def patch():
import
traceback
from
unittest
import
TextTestResult
,
TextTestRunner
TextTestResult_addError
=
TextTestResult
.
addError
.
__func__
TextTestResult_addError
=
TextTestResult
.
addError
import
six
if
six
.
PY2
:
TextTestResult_addError
=
TextTestResult_addError
.
__func__
def
addError
(
self
,
test
,
err
):
if
isinstance
(
err
[
1
],
SetupSiteError
):
self
.
errors
.
append
(
None
)
...
...
@@ -40,7 +43,10 @@ def patch():
self
.
stream
.
writeln
(
"SUCCESS: %s"
%
self
.
getDescription
(
test
))
TextTestResult
.
printErrors
=
printErrors
TextTestRunner_run
=
TextTestRunner
.
run
.
__func__
TextTestRunner_run
=
TextTestRunner
.
run
import
six
if
six
.
PY2
:
TextTestRunner_run
=
TextTestRunner_run
.
__func__
def
run
(
self
,
test
):
def
t
(
result
):
try
:
...
...
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