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
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
31c84fc5
Commit
31c84fc5
authored
Mar 15, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: update classes using __metaclass__
parent
a49b216e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
bt5/erp5_forge/ModuleComponentTemplateItem/portal_components/module.erp5.WorkingCopy.py
...TemplateItem/portal_components/module.erp5.WorkingCopy.py
+8
-8
product/ERP5/bootstrap/erp5_core/ModuleComponentTemplateItem/portal_components/module.erp5.ExpandPolicy.py
...emplateItem/portal_components/module.erp5.ExpandPolicy.py
+10
-8
No files found.
bt5/erp5_forge/ModuleComponentTemplateItem/portal_components/module.erp5.WorkingCopy.py
View file @
31c84fc5
...
@@ -43,6 +43,7 @@ from Products.ERP5.Document.BusinessTemplate import BusinessTemplateFolder
...
@@ -43,6 +43,7 @@ from Products.ERP5.Document.BusinessTemplate import BusinessTemplateFolder
from
Products.ERP5Type.Utils
import
simple_decorator
from
Products.ERP5Type.Utils
import
simple_decorator
from
six
import
string_types
as
basestring
from
six
import
string_types
as
basestring
from
six.moves
import
range
from
six.moves
import
range
import
six
@
simple_decorator
@
simple_decorator
def
selfcached
(
func
):
def
selfcached
(
func
):
...
@@ -78,20 +79,19 @@ def issubdir(parent, child):
...
@@ -78,20 +79,19 @@ def issubdir(parent, child):
return
parent
==
child
or
child
.
startswith
(
parent
+
os
.
sep
)
return
parent
==
child
or
child
.
startswith
(
parent
+
os
.
sep
)
ImplicitType
=
type
(
Implicit
)
ImplicitType
=
type
(
Implicit
)
class
WorkingCopyMetaClass
(
ImplicitType
):
def
__init__
(
cls
,
name
,
bases
,
d
):
# pylint: disable=no-self-argument,super-init-not-called
ImplicitType
.
__init__
(
cls
,
name
,
bases
,
d
)
# pylint: disable=non-parent-init-called
if
cls
.
reference
:
cls
.
_registry
.
append
((
cls
.
reference
,
cls
))
class
WorkingCopy
(
Implicit
):
class
WorkingCopy
(
six
.
with_metaclass
(
WorkingCopyMetaClass
,
Implicit
)):
__allow_access_to_unprotected_subobjects__
=
1
__allow_access_to_unprotected_subobjects__
=
1
_registry
=
[]
_registry
=
[]
reference
=
None
reference
=
None
class
__metaclass__
(
ImplicitType
):
def
__init__
(
cls
,
name
,
bases
,
d
):
# pylint: disable=no-self-argument,super-init-not-called
ImplicitType
.
__init__
(
cls
,
name
,
bases
,
d
)
# pylint: disable=non-parent-init-called
if
cls
.
reference
:
cls
.
_registry
.
append
((
cls
.
reference
,
cls
))
def
__init__
(
self
,
path
=
None
,
restricted
=
False
):
def
__init__
(
self
,
path
=
None
,
restricted
=
False
):
if
path
:
if
path
:
self
.
working_copy
=
self
.
checkWorkingPath
(
path
,
restricted
)
self
.
working_copy
=
self
.
checkWorkingPath
(
path
,
restricted
)
...
...
product/ERP5/bootstrap/erp5_core/ModuleComponentTemplateItem/portal_components/module.erp5.ExpandPolicy.py
View file @
31c84fc5
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
##############################################################################
##############################################################################
import
six
from
time
import
time
from
time
import
time
import
transaction
import
transaction
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
...
@@ -54,16 +55,17 @@ policy_dict = {} # {None: preferred, 'foo_bar': FooBar}
...
@@ -54,16 +55,17 @@ policy_dict = {} # {None: preferred, 'foo_bar': FooBar}
VERTICAL_EXPAND_TIMEOUT
=
5
# XXX: hardcoded for the moment
VERTICAL_EXPAND_TIMEOUT
=
5
# XXX: hardcoded for the moment
class
_Policy
(
object
):
class
_PolicyMetaClass
(
type
):
"""Automatically register policies in policy_dict"""
def
__init__
(
cls
,
name
,
bases
,
d
):
type
.
__init__
(
cls
,
name
,
bases
,
d
)
if
name
[
0
]
!=
'_'
:
policy_dict
[
convertToLowerCase
(
name
)[
1
:]]
=
cls
class
_Policy
(
six
.
with_metaclass
(
_PolicyMetaClass
,
object
)):
"""Base class of policies for RuleMixin.expand and SimulationMovement.expand
"""Base class of policies for RuleMixin.expand and SimulationMovement.expand
"""
"""
class
__metaclass__
(
type
):
"""Automatically register policies in policy_dict"""
def
__init__
(
cls
,
name
,
bases
,
d
):
type
.
__init__
(
cls
,
name
,
bases
,
d
)
if
name
[
0
]
!=
'_'
:
policy_dict
[
convertToLowerCase
(
name
)[
1
:]]
=
cls
def
__init__
(
self
,
activate_kw
=
None
):
def
__init__
(
self
,
activate_kw
=
None
):
self
.
activate_kw
=
activate_kw
self
.
activate_kw
=
activate_kw
...
...
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