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
d1b2669a
Commit
d1b2669a
authored
Feb 26, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "lazy_class: WIP new metaclass"
This reverts commit 6135f41f49092270bdaff614bbd25aa7c0c62a41.
parent
f0dfffa6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
35 deletions
+38
-35
product/ERP5Type/dynamic/lazy_class.py
product/ERP5Type/dynamic/lazy_class.py
+38
-35
No files found.
product/ERP5Type/dynamic/lazy_class.py
View file @
d1b2669a
...
@@ -22,6 +22,44 @@ from . import persistent_migration
...
@@ -22,6 +22,44 @@ from . import persistent_migration
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
import
six
import
six
if
six
.
PY2
:
class
ERP5BaseBroken_
(
Broken
,
ERP5Base
,
PersistentBroken
):
pass
else
:
class
ERP5BaseBroken_
(
ERP5Base
,
PersistentBroken
):
pass
class
ERP5BaseBroken
(
ERP5BaseBroken_
):
# PersistentBroken can't be reused directly
# because its « layout differs from 'GhostPortalType' »
# This prevents serialize (ZODB) from reloading the class during commit
# (which would look for __Broken_newargs__ which is not present)
__getnewargs__
=
None
def
__metaclass__
(
name
,
base
,
d
):
d
=
dict
(
PersistentBroken
.
__dict__
,
**
d
)
for
x
in
'__dict__'
,
'__metaclass__'
,
'__weakref__'
:
del
d
[
x
]
def
get
(
x
):
def
get
(
self
):
d
=
self
.
__dict__
try
:
return
d
.
get
(
'__Broken_state__'
,
d
)[
x
]
except
KeyError
:
return
getattr
(
self
.
__class__
,
x
)
return
property
(
get
)
for
x
in
'id'
,
'title'
:
d
[
x
]
=
get
(
x
)
return
type
(
name
,
base
,
d
)
def
__getattr__
(
self
,
name
):
try
:
return
self
.
__dict__
[
'__Broken_state__'
][
name
]
# TypeError: SynchronizationTool => SynchronisationTool
except
(
KeyError
,
TypeError
):
raise
AttributeError
(
"state of broken %r object has no %r key"
%
(
self
.
__class__
.
__name__
,
name
))
# the meta class of a derived class must be a subclass of all of its bases:
# the meta class of a derived class must be a subclass of all of its bases:
# since a portal type derives from both Zope Extension classes and
# since a portal type derives from both Zope Extension classes and
...
@@ -361,38 +399,3 @@ def generateLazyPortalTypeClass(portal_type_name):
...
@@ -361,38 +399,3 @@ def generateLazyPortalTypeClass(portal_type_name):
return
PortalTypeMetaClass
(
portal_type_name
,
return
PortalTypeMetaClass
(
portal_type_name
,
(
InitGhostBase
,),
(
InitGhostBase
,),
dict
(
portal_type
=
portal_type_name
))
dict
(
portal_type
=
portal_type_name
))
class
ERP5BaseBrokenMetaClass
(
PortalTypeMetaClass
):
def
__new__
(
cls
,
name
,
bases
,
d
):
d
=
dict
(
PersistentBroken
.
__dict__
,
**
d
)
for
x
in
'__dict__'
,
'__weakref__'
:
del
d
[
x
]
if
six
.
PY2
:
del
d
[
'__metaclass__'
]
def
get
(
x
):
def
get
(
self
):
d
=
self
.
__dict__
try
:
return
d
.
get
(
'__Broken_state__'
,
d
)[
x
]
except
KeyError
:
return
getattr
(
self
.
__class__
,
x
)
return
property
(
get
)
for
x
in
'id'
,
'title'
:
d
[
x
]
=
get
(
x
)
return
super
(
ERP5BaseBrokenMetaClass
,
cls
).
__new__
(
cls
,
name
,
bases
,
d
)
class
ERP5BaseBroken
(
six
.
with_metaclass
(
ERP5BaseBrokenMetaClass
,
Broken
,
ERP5Base
,
PersistentBroken
)):
# This prevents serialize (ZODB) from reloading the class during commit
# (which would look for __Broken_newargs__ which is not present)
__getnewargs__
=
None
def
__getattr__
(
self
,
name
):
try
:
return
self
.
__dict__
[
'__Broken_state__'
][
name
]
# TypeError: SynchronizationTool => SynchronisationTool
except
(
KeyError
,
TypeError
):
raise
AttributeError
(
"state of broken %r object has no %r key"
%
(
self
.
__class__
.
__name__
,
name
))
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