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
Nikola Balog
erp5
Commits
dca6727d
Commit
dca6727d
authored
May 21, 2020
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: ZODB Components: Products import compatibility.
parent
daafd0e6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
10 deletions
+77
-10
product/ERP5Type/Core/ToolComponent.py
product/ERP5Type/Core/ToolComponent.py
+2
-2
product/ERP5Type/ERP5Site.py
product/ERP5Type/ERP5Site.py
+39
-1
product/ERP5Type/dynamic/component_package.py
product/ERP5Type/dynamic/component_package.py
+36
-7
No files found.
product/ERP5Type/Core/ToolComponent.py
View file @
dca6727d
...
@@ -61,8 +61,8 @@ class ToolComponent(DocumentComponent):
...
@@ -61,8 +61,8 @@ class ToolComponent(DocumentComponent):
# Should we really use ERP5 Product and not ERP5Type considering that ERP5
# Should we really use ERP5 Product and not ERP5Type considering that ERP5
# may be gone at some point? Or the other way around? For now, all tools
# may be gone at some point? Or the other way around? For now, all tools
# have meta_type='ERP5 ...' so just use ERP5 Product.
# have meta_type='ERP5 ...' so just use ERP5 Product.
import
Products.ERP5
import
Products.ERP5
Type
toolinit
=
Products
.
ERP5
.
__FactoryDispatcher__
.
toolinit
toolinit
=
Products
.
ERP5
Type
.
__FactoryDispatcher__
.
toolinit
# Products.CMFCore.utils.ToolInit.initialize()
# Products.CMFCore.utils.ToolInit.initialize()
tool_class
.
__factory_meta_type__
=
toolinit
.
meta_type
tool_class
.
__factory_meta_type__
=
toolinit
.
meta_type
tool_class
.
icon
=
'misc_/%s/%s'
%
(
'ERP5'
,
toolinit
.
icon
)
tool_class
.
icon
=
'misc_/%s/%s'
%
(
'ERP5'
,
toolinit
.
icon
)
...
...
product/ERP5Type/ERP5Site.py
View file @
dca6727d
...
@@ -226,7 +226,7 @@ class _site(threading.local):
...
@@ -226,7 +226,7 @@ class _site(threading.local):
self
.
site
=
[
x
for
x
in
self
.
site
if
x
[
0
]
is
not
app
]
self
.
site
=
[
x
for
x
in
self
.
site
if
x
[
0
]
is
not
app
]
getSite
,
setSite
=
_site
()
getSite
,
setSite
=
_site
()
all_product_installed_portal_id_set
=
set
()
class
ERP5Site
(
ResponseHeaderGenerator
,
FolderMixIn
,
CMFSite
,
CacheCookieMixin
):
class
ERP5Site
(
ResponseHeaderGenerator
,
FolderMixIn
,
CMFSite
,
CacheCookieMixin
):
"""
"""
...
@@ -403,6 +403,44 @@ class ERP5Site(ResponseHeaderGenerator, FolderMixIn, CMFSite, CacheCookieMixin):
...
@@ -403,6 +403,44 @@ class ERP5Site(ResponseHeaderGenerator, FolderMixIn, CMFSite, CacheCookieMixin):
# This should only happen before erp5_core is installed
# This should only happen before erp5_core is installed
synchronizeDynamicModules
(
self
)
synchronizeDynamicModules
(
self
)
else
:
else
:
global
all_product_installed_portal_id_set
from
Products.ERP5Type.dynamic
import
aq_method_lock
if
self
.
id
not
in
all_product_installed_portal_id_set
:
with
aq_method_lock
:
all_product_installed_portal_id_set
.
add
(
self
.
id
)
LOG
(
'ERP5Site'
,
INFO
,
'===> Creating mapping of old FS to new ZODB Components imports'
)
import
erp5.component
if
not
getattr
(
erp5
.
component
,
'filesystem_import_dict'
,
None
):
filesystem_import_dict
=
{}
for
component
in
component_tool
.
objectValues
():
if
(
component
.
getValidationState
()
==
'validated'
and
component
.
getSourceReference
()
is
not
None
):
if
component
.
getReference
()
==
'CompositionMixin'
:
continue
filesystem_import_dict
[
component
.
getSourceReference
()]
=
'%s.%s'
%
(
component
.
_getDynamicModuleNamespace
(),
component
.
getReference
())
erp5
.
component
.
filesystem_import_dict
=
filesystem_import_dict
LOG
(
'ERP5Site'
,
INFO
,
'===> Importing all Products'
)
from
OFS.Application
import
import_products
import_products
(
everything
=
True
)
LOG
(
'ERP5Site'
,
INFO
,
'===> Installing all Products'
)
from
OFS.Application
import
install_products
install_products
(
self
.
aq_parent
,
everything
=
True
)
# TODO-BEFORE-MERGE: Fill document_class_registry to load
# classes. It should probably be done in initializeProduct()....
from
Products.ERP5Type.InitGenerator
import
initializeProductDocumentRegistry
initializeProductDocumentRegistry
()
LOG
(
'ERP5Site'
,
INFO
,
'===> Reset all ZODB Components and Portal Type classes'
)
component_tool
.
reset
(
force
=
True
)
LOG
(
'ERP5Site'
,
INFO
,
'===> All Products installed'
)
if
not
component_tool
.
reset
():
if
not
component_tool
.
reset
():
# Portal Types may have been reset even if Components haven't
# Portal Types may have been reset even if Components haven't
# (change of Interaction Workflow...)
# (change of Interaction Workflow...)
...
...
product/ERP5Type/dynamic/component_package.py
View file @
dca6727d
...
@@ -34,6 +34,7 @@ import sys
...
@@ -34,6 +34,7 @@ import sys
import
imp
import
imp
import
collections
import
collections
from
Products.ERP5Type
import
product_path
as
ERP5Type_product_path
from
Products.ERP5Type.ERP5Site
import
getSite
from
Products.ERP5Type.ERP5Site
import
getSite
from
.
import
aq_method_lock
from
.
import
aq_method_lock
from
types
import
ModuleType
from
types
import
ModuleType
...
@@ -109,10 +110,26 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -109,10 +110,26 @@ class ComponentDynamicPackage(ModuleType):
perhaps because the Finder of another Component Package could do it or
perhaps because the Finder of another Component Package could do it or
because this is a filesystem module...
because this is a filesystem module...
"""
"""
# Ignore imports with a path which are filesystem-only and any
# ZODB Components
# absolute imports which does not start with this package prefix,
if
not
path
:
# None there means that "normal" sys.path will be used
if
not
fullname
.
startswith
(
self
.
_namespace_prefix
):
if
path
or
not
fullname
.
startswith
(
self
.
_namespace_prefix
):
return
None
# FS import backward compatibility
else
:
if
not
[
p
for
p
in
path
if
(
not
p
.
startswith
(
ERP5Type_product_path
)
# TODO-BEFORE-MERGE: Would not work for customer Products...
# and p.startswith(os.path.realpath(ERP5Type_product_path + '/..'))
)]:
return
None
import
erp5.component
try
:
fullname
=
erp5
.
component
.
filesystem_import_dict
[
fullname
]
except
Exception
:
return
None
else
:
if
not
fullname
.
startswith
(
self
.
_namespace_prefix
):
return
None
return
None
import_lock_held
=
True
import_lock_held
=
True
...
@@ -219,6 +236,14 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -219,6 +236,14 @@ class ComponentDynamicPackage(ModuleType):
module for any reason...
module for any reason...
"""
"""
site
=
getSite
()
site
=
getSite
()
if
fullname
.
startswith
(
'Products.'
):
module_fullname_filesystem
=
fullname
import
erp5.component
fullname
=
erp5
.
component
.
filesystem_import_dict
[
module_fullname_filesystem
]
else
:
module_fullname_filesystem
=
None
name
=
fullname
[
len
(
self
.
_namespace_prefix
):]
name
=
fullname
[
len
(
self
.
_namespace_prefix
):]
# if only Version package (erp5.component.XXX.VERSION_version) is
# if only Version package (erp5.component.XXX.VERSION_version) is
...
@@ -288,6 +313,8 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -288,6 +313,8 @@ class ComponentDynamicPackage(ModuleType):
sys
.
modules
[
module_fullname
]
=
module
sys
.
modules
[
module_fullname
]
=
module
if
module_fullname_alias
:
if
module_fullname_alias
:
sys
.
modules
[
module_fullname_alias
]
=
module
sys
.
modules
[
module_fullname_alias
]
=
module
if
module_fullname_filesystem
:
sys
.
modules
[
module_fullname_filesystem
]
=
module
# This must be set for imports at least (see PEP 302)
# This must be set for imports at least (see PEP 302)
module
.
__file__
=
'<'
+
relative_url
+
'>'
module
.
__file__
=
'<'
+
relative_url
+
'>'
...
@@ -308,6 +335,8 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -308,6 +335,8 @@ class ComponentDynamicPackage(ModuleType):
del
sys
.
modules
[
module_fullname
]
del
sys
.
modules
[
module_fullname
]
if
module_fullname_alias
:
if
module_fullname_alias
:
del
sys
.
modules
[
module_fullname_alias
]
del
sys
.
modules
[
module_fullname_alias
]
if
module_fullname_filesystem
:
del
sys
.
modules
[
module_fullname_filesystem
]
raise
ImportError
(
raise
ImportError
(
"%s: cannot load Component %s (%s)"
%
(
fullname
,
name
,
error
)),
\
"%s: cannot load Component %s (%s)"
%
(
fullname
,
name
,
error
)),
\
...
@@ -442,8 +471,8 @@ class ToolComponentDynamicPackage(ComponentDynamicPackage):
...
@@ -442,8 +471,8 @@ class ToolComponentDynamicPackage(ComponentDynamicPackage):
"""
"""
Reset CMFCore list of Tools (manage_addToolForm)
Reset CMFCore list of Tools (manage_addToolForm)
"""
"""
import
Products.ERP5
import
Products.ERP5
Type
toolinit
=
Products
.
ERP5
.
__FactoryDispatcher__
.
toolinit
toolinit
=
Products
.
ERP5
Type
.
__FactoryDispatcher__
.
toolinit
reset_tool_set
=
set
()
reset_tool_set
=
set
()
for
tool
in
toolinit
.
tools
:
for
tool
in
toolinit
.
tools
:
if
not
tool
.
__module__
.
startswith
(
self
.
_namespace_prefix
):
if
not
tool
.
__module__
.
startswith
(
self
.
_namespace_prefix
):
...
...
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