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
Paul Graydon
erp5
Commits
ee593f80
Commit
ee593f80
authored
Feb 21, 2022
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
9b74110a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
28 deletions
+47
-28
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+25
-24
product/ERP5Type/ZopePatch.py
product/ERP5Type/ZopePatch.py
+3
-2
product/ERP5Type/__init__.py
product/ERP5Type/__init__.py
+11
-0
product/ERP5Type/patches/my2to3.py
product/ERP5Type/patches/my2to3.py
+0
-0
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+8
-2
No files found.
product/ERP5Type/Base.py
View file @
ee593f80
...
@@ -33,8 +33,6 @@ from copy import copy
...
@@ -33,8 +33,6 @@ from copy import copy
import
warnings
import
warnings
import
types
import
types
import
thread
,
threading
import
thread
,
threading
import
os
from
lib2to3.pgen2.parse
import
ParseError
from
BTrees.OOBTree
import
OOBTree
from
BTrees.OOBTree
import
OOBTree
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
...
@@ -45,7 +43,6 @@ from AccessControl.SecurityManagement import getSecurityManager
...
@@ -45,7 +43,6 @@ from AccessControl.SecurityManagement import getSecurityManager
from
AccessControl.ZopeGuards
import
guarded_getattr
from
AccessControl.ZopeGuards
import
guarded_getattr
from
Acquisition
import
aq_base
,
aq_inner
,
aq_acquire
,
aq_chain
from
Acquisition
import
aq_base
,
aq_inner
,
aq_acquire
,
aq_chain
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
my2to3.trace
import
apply_fixers
import
OFS.History
import
OFS.History
from
OFS.SimpleItem
import
SimpleItem
from
OFS.SimpleItem
import
SimpleItem
from
OFS.PropertyManager
import
PropertyManager
from
OFS.PropertyManager
import
PropertyManager
...
@@ -866,27 +863,6 @@ class Base(
...
@@ -866,27 +863,6 @@ class Base(
self
.
uid
=
uid
# Else it will be generated when we need it
self
.
uid
=
uid
# Else it will be generated when we need it
self
.
sid
=
sid
self
.
sid
=
sid
def
__setstate__
(
self
,
state
):
if
os
.
environ
.
get
(
"MY2TO3_ACTION"
)
==
"trace"
and
\
self
.
getPortalType
()
in
[
"Document Component"
,
"Extension Component"
,
"Interface Component"
,
"Mixin Component"
,
"Module Component"
,
"Test Component"
,
"Tool Component"
,
]:
# See Products.ERP5Type.patches.my2to3_patch
# Apply "trace" fixers on the fly
# Note: The modifications are not saved (unless it is done explicitly,
# e.g. the user saves manually).
text_content
=
state
.
get
(
'text_content'
)
if
text_content
:
try
:
state
[
'text_content'
]
=
apply_fixers
(
text_content
,
state
[
'id'
])
except
ParseError
:
# text_content is not valid code
pass
super
(
Base
,
self
).
__setstate__
(
state
)
# XXX This is necessary to override getId which is also defined in SimpleItem.
# XXX This is necessary to override getId which is also defined in SimpleItem.
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getId'
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getId'
)
getId
=
BaseAccessor
.
Getter
(
'getId'
,
'id'
,
'string'
)
getId
=
BaseAccessor
.
Getter
(
'getId'
,
'id'
,
'string'
)
...
@@ -3640,6 +3616,31 @@ class Base(
...
@@ -3640,6 +3616,31 @@ class Base(
id_generator_state
[
group
].
value
=
new_next_id
id_generator_state
[
group
].
value
=
new_next_id
return
range
(
next_id
,
new_next_id
)
return
range
(
next_id
,
new_next_id
)
from
Products.ERP5Type
import
MY2TO3_ACTION
if
MY2TO3_ACTION
==
'trace'
:
def
__setstate__
(
self
,
state
):
if
self
.
getPortalType
()
in
(
"Document Component"
,
"Extension Component"
,
"Interface Component"
,
"Mixin Component"
,
"Module Component"
,
"Test Component"
,
"Tool Component"
):
# See Products.ERP5Type.patches.my2to3_patch
# Apply "trace" fixers on the fly
# Note: The modifications are not saved (unless it is done explicitly,
# e.g. the user saves manually).
text_content
=
state
.
get
(
'text_content'
)
if
text_content
:
try
:
state
[
'text_content'
]
=
apply_fixers
(
text_content
,
state
[
'id'
])
except
ParseError
:
# text_content is not valid code
pass
super
(
Base
,
self
).
__setstate__
(
state
)
Base
.
__setstate__
=
__setstate__
InitializeClass
(
Base
)
InitializeClass
(
Base
)
from
Products.CMFCore.interfaces
import
IContentish
from
Products.CMFCore.interfaces
import
IContentish
...
...
product/ERP5Type/ZopePatch.py
View file @
ee593f80
...
@@ -20,10 +20,11 @@
...
@@ -20,10 +20,11 @@
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
##############################################################################
##############################################################################
from
Products.ERP5Type
import
WITH_LEGACY_WORKFLOW
from
Products.ERP5Type
import
WITH_LEGACY_WORKFLOW
,
MY2TO3_ACTION
# Load all monkey patches
# Load all monkey patches
from
Products.ERP5Type.patches
import
my2to3_patch
if
MY2TO3_ACTION
is
not
None
:
from
Products.ERP5Type.patches
import
my2to3_patch
from
Products.ERP5Type.patches
import
WSGIPublisher
from
Products.ERP5Type.patches
import
WSGIPublisher
from
Products.ERP5Type.patches
import
HTTPRequest
from
Products.ERP5Type.patches
import
HTTPRequest
from
Products.ERP5Type.patches
import
AccessControl_patch
from
Products.ERP5Type.patches
import
AccessControl_patch
...
...
product/ERP5Type/__init__.py
View file @
ee593f80
...
@@ -32,6 +32,17 @@
...
@@ -32,6 +32,17 @@
"""
"""
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
App.config
import
getConfiguration
from
App.config
import
getConfiguration
# Conditionally apply patches/my2to3.py
try
:
from
my2to3.trace
import
apply_fixers
from
lib2to3.pgen2.parse
import
ParseError
except
ImportError
:
MY2TO3_ACTION
=
None
else
:
import
os
MY2TO3_ACTION
=
os
.
environ
.
get
(
"MY2TO3_ACTION"
)
from
.patches
import
python
,
pylint
,
globalrequest
from
.patches
import
python
,
pylint
,
globalrequest
from
zLOG
import
LOG
,
INFO
from
zLOG
import
LOG
,
INFO
DISPLAY_BOOT_PROCESS
=
False
DISPLAY_BOOT_PROCESS
=
False
...
...
product/ERP5Type/patches/my2to3
_patch
.py
→
product/ERP5Type/patches/my2to3.py
View file @
ee593f80
File moved
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
ee593f80
...
@@ -42,7 +42,6 @@ from ZODB.broken import BrokenModified
...
@@ -42,7 +42,6 @@ from ZODB.broken import BrokenModified
from
zExceptions
import
Forbidden
,
NotFound
from
zExceptions
import
Forbidden
,
NotFound
from
AccessControl.SecurityManagement
import
\
from
AccessControl.SecurityManagement
import
\
getSecurityManager
,
setSecurityManager
,
noSecurityManager
getSecurityManager
,
setSecurityManager
,
noSecurityManager
from
Products.ERP5Type.dynamic.persistent_migration
import
Base__setstate__
from
Products.ERP5Type.dynamic.portal_type_class
import
synchronizeDynamicModules
from
Products.ERP5Type.dynamic.portal_type_class
import
synchronizeDynamicModules
from
Products.ERP5Type.dynamic.lazy_class
import
ERP5BaseBroken
,
InitGhostBase
from
Products.ERP5Type.dynamic.lazy_class
import
ERP5BaseBroken
,
InitGhostBase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
...
@@ -78,7 +77,14 @@ class TestPortalTypeClass(ERP5TypeTestCase):
...
@@ -78,7 +77,14 @@ class TestPortalTypeClass(ERP5TypeTestCase):
self
.
assertEqual
(
klass
.
__module__
,
self
.
assertEqual
(
klass
.
__module__
,
migrated
and
'erp5.portal_type'
or
'erp5.component.document.erp5_version.Person'
)
migrated
and
'erp5.portal_type'
or
'erp5.component.document.erp5_version.Person'
)
self
.
assertEqual
(
klass
.
__name__
,
'Person'
)
self
.
assertEqual
(
klass
.
__name__
,
'Person'
)
self
.
assertEqual
(
klass
.
__setstate__
.
im_func
is
Base__setstate__
.
im_func
,
migrated
)
from
Products.ERP5Type
import
MY2TO3_ACTION
if
MY2TO3_ACTION
==
'trace'
:
from
Products.ERP5Type.dynamic.persistent_migration
import
Base__setstate__
self
.
assertEqual
(
klass
.
__setstate__
.
im_func
is
Base__setstate__
.
im_func
,
migrated
)
else
:
from
persistent
import
Persistent
self
.
assertEqual
(
klass
.
__setstate__
is
Persistent
.
__setstate__
,
migrated
)
# Import a .xml containing a Person created with the full module name
# Import a .xml containing a Person created with the full module name
self
.
importObjectFromFile
(
person_module
,
'non_migrated_person.xml'
)
self
.
importObjectFromFile
(
person_module
,
'non_migrated_person.xml'
)
...
...
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