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
Lukas Niegsch
erp5
Commits
9dbe48b4
Commit
9dbe48b4
authored
Apr 25, 2022
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py3: Products.ERP5Type.dynamic.
parent
e9c618bf
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
11 deletions
+25
-11
product/ERP5Type/dynamic/accessor_holder.py
product/ERP5Type/dynamic/accessor_holder.py
+2
-2
product/ERP5Type/dynamic/component_package.py
product/ERP5Type/dynamic/component_package.py
+14
-4
product/ERP5Type/dynamic/dynamic_module.py
product/ERP5Type/dynamic/dynamic_module.py
+2
-1
product/ERP5Type/dynamic/lazy_class.py
product/ERP5Type/dynamic/lazy_class.py
+2
-2
product/ERP5Type/dynamic/portal_type_class.py
product/ERP5Type/dynamic/portal_type_class.py
+5
-2
No files found.
product/ERP5Type/dynamic/accessor_holder.py
View file @
9dbe48b4
...
...
@@ -98,7 +98,7 @@ class AccessorHolderModuleType(ModuleType):
"""
Clear the content of the module
"""
for
klass
in
self
.
__dict__
.
values
(
):
for
klass
in
ensure_list
(
self
.
__dict__
.
values
()
):
if
isinstance
(
klass
,
AccessorHolderType
):
# Delete these attributes (computed on the portal type class
# from its accessor holder) before deleting the class itself
...
...
@@ -336,7 +336,7 @@ def applyCategoryAsRelatedValueAccessor(accessor_holder,
accessor
=
RelatedValue
.
IdListGetter
(
accessor_name
+
'RelatedIds'
,
category_id
)
accessor_holder
.
registerAccessor
(
accessor
,
read_permission
)
for
accessor_class
,
accessor_name_list
in
related_accessor_definition_dict
.
items
():
for
accessor_class
,
accessor_name_list
in
related_accessor_definition_dict
.
ite
rite
ms
():
for
accessor_name
in
accessor_name_list
:
accessor
=
accessor_class
(
accessor_name
%
uppercase_category_id
,
category_id
)
accessor_holder
.
registerAccessor
(
accessor
,
read_permission
)
...
...
product/ERP5Type/dynamic/component_package.py
View file @
9dbe48b4
...
...
@@ -30,11 +30,13 @@
# There is absolutely no reason to use relative imports when loading a Component
from
__future__
import
absolute_import
import
six
import
sys
import
imp
import
collections
from
six
import
reraise
from
Products.ERP5Type.Utils
import
ensure_list
from
Products.ERP5.ERP5Site
import
getSite
from
Products.ERP5Type
import
product_path
as
ERP5Type_product_path
from
.
import
aq_method_lock
...
...
@@ -51,6 +53,12 @@ class ComponentVersionPackage(ModuleType):
"""
__path__
=
[]
try
:
ModuleNotFoundError
except
NameError
:
# < 3.6
class
ModuleNotFoundError
(
ImportError
):
pass
class
ComponentDynamicPackage
(
ModuleType
):
"""
A top-level component is a package as it contains modules, this is required
...
...
@@ -420,8 +428,10 @@ class ComponentDynamicPackage(ModuleType):
# load_module(), and returning module 'name' in contrary to __import__
# returning 'erp5' (requiring fromlist parameter which is slower)
return
import_module
(
fullname
)
except
ModuleNotFoundError
:
pass
except
ImportError
as
e
:
if
str
(
e
)
!=
"No module named "
+
name
:
if
s
ix
.
PY3
or
s
tr
(
e
)
!=
"No module named "
+
name
:
LOG
(
"ERP5Type.dynamic"
,
WARNING
,
"Could not load Component module %r"
%
fullname
,
error
=
True
)
...
...
@@ -443,10 +453,10 @@ class ComponentDynamicPackage(ModuleType):
# Force reload of ModuleSecurityInfo() as it may have been changed in
# the source code
for
modsec_dict
in
_moduleSecurity
,
_appliedModuleSecurity
:
for
k
in
modsec_dict
.
keys
(
):
for
k
in
ensure_list
(
modsec_dict
.
keys
()
):
if
k
.
startswith
(
self
.
_namespace
):
del
modsec_dict
[
k
]
for
k
,
v
in
MNAME_MAP
.
items
(
):
for
k
,
v
in
ensure_list
(
MNAME_MAP
.
items
()
):
if
v
.
startswith
(
self
.
_namespace
):
del
MNAME_MAP
[
k
]
...
...
@@ -454,7 +464,7 @@ class ComponentDynamicPackage(ModuleType):
if
k
.
startswith
(
'Products.'
):
del
sys
.
modules
[
k
]
for
name
,
module
in
package
.
__dict__
.
items
(
):
for
name
,
module
in
ensure_list
(
package
.
__dict__
.
items
()
):
if
name
[
0
]
==
'_'
or
not
isinstance
(
module
,
ModuleType
):
continue
...
...
product/ERP5Type/dynamic/dynamic_module.py
View file @
9dbe48b4
...
...
@@ -28,6 +28,7 @@ from __future__ import absolute_import
#
##############################################################################
from
Products.ERP5Type.Utils
import
ensure_list
from
types
import
ModuleType
from
.
import
aq_method_lock
import
sys
...
...
@@ -82,7 +83,7 @@ class RefManager(dict):
Remove cache items with no Request Left.
"""
for
(
current_last_sync
,
(
request_obj_weakset
,
_
))
in
self
.
items
(
):
(
request_obj_weakset
,
_
))
in
ensure_list
(
self
.
items
()
):
if
not
request_obj_weakset
:
del
self
[
current_last_sync
]
...
...
product/ERP5Type/dynamic/lazy_class.py
View file @
9dbe48b4
...
...
@@ -244,7 +244,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
erp5.portal_type.XXX, GhostBaseMetaClass instance, *TAIL
"""
if
not
cls
.
__isghost__
:
for
attr
in
cls
.
__dict__
.
keys
(
):
for
attr
in
ensure_list
(
cls
.
__dict__
.
keys
()
):
if
attr
not
in
(
'__module__'
,
'__doc__'
,
'__setstate__'
,
...
...
@@ -317,7 +317,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
result
=
PropertyHolder
.
_getPropertyHolderItemList
(
cls
)
for
parent
in
cls
.
mro
():
if
parent
.
__module__
.
startswith
(
'erp5.accessor_holder'
):
for
x
in
parent
.
__dict__
.
items
():
for
x
in
parent
.
__dict__
.
ite
rite
ms
():
if
x
[
0
]
not
in
PropertyHolder
.
RESERVED_PROPERTY_SET
:
result
.
append
(
x
)
return
result
...
...
product/ERP5Type/dynamic/portal_type_class.py
View file @
9dbe48b4
...
...
@@ -27,6 +27,7 @@
#
##############################################################################
import
six
import
os
import
inspect
import
transaction
...
...
@@ -36,7 +37,7 @@ from Products.ERP5Type.mixin.temporary import TemporaryDocumentMixin
from
Products.ERP5Type.Base
import
resetRegisteredWorkflowMethod
from
.
import
aq_method_lock
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type.Utils
import
setDefaultClassProperties
from
Products.ERP5Type.Utils
import
setDefaultClassProperties
,
ensure_list
from
Products.ERP5Type
import
document_class_registry
,
mixin_class_registry
from
Products.ERP5Type.dynamic.accessor_holder
import
createAllAccessorHolderList
from
Products.ERP5Type.Accessor.Constant
import
Getter
as
ConstantGetter
...
...
@@ -60,6 +61,8 @@ ACQUIRE_LOCAL_ROLE_GETTER_DICT = {
for
acquire_local_role
in
(
False
,
True
)
}
if
six
.
PY3
:
StandardError
=
Exception
def
_importFilesystemClass
(
classpath
):
try
:
module_path
,
class_name
=
classpath
.
rsplit
(
'.'
,
1
)
...
...
@@ -540,7 +543,7 @@ def synchronizeDynamicModules(context, force=False):
erp5
.
accessor_holder
.
clear
()
erp5
.
accessor_holder
.
property_sheet
.
clear
()
for
name
in
e
rp5
.
accessor_holder
.
portal_type
.
__dict__
.
keys
(
):
for
name
in
e
nsure_list
(
erp5
.
accessor_holder
.
portal_type
.
__dict__
.
keys
()
):
if
name
[
0
]
!=
'_'
:
delattr
(
erp5
.
accessor_holder
.
portal_type
,
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