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
Léo-Paul Géneau
erp5
Commits
6b765217
Commit
6b765217
authored
Jan 18, 2012
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move initializeDynamicModules to dynamic_module, meaningful for components as well.
parent
59110c92
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
59 deletions
+91
-59
product/ERP5Type/Utils.py
product/ERP5Type/Utils.py
+1
-1
product/ERP5Type/dynamic/dynamic_module.py
product/ERP5Type/dynamic/dynamic_module.py
+78
-0
product/ERP5Type/dynamic/portal_type_class.py
product/ERP5Type/dynamic/portal_type_class.py
+12
-58
No files found.
product/ERP5Type/Utils.py
View file @
6b765217
...
...
@@ -1042,7 +1042,7 @@ def initializeProduct( context,
try
:
import
erp5.portal_type
except
ImportError
:
from
dynamic.
portal_type_class
import
initializeDynamicModules
from
dynamic.
dynamic_module
import
initializeDynamicModules
initializeDynamicModules
()
import
erp5.portal_type
...
...
product/ERP5Type/dynamic/dynamic_module.py
View file @
6b765217
##############################################################################
#
# Copyright (c) 2010-2012 Nexedi SARL and Contributors. All Rights Reserved.
# Nicolas Dumazet <nicolas.dumazet@nexedi.com>
# Arnaud Fontaine <arnaud.fontaine@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from
types
import
ModuleType
import
sys
import
threading
...
...
@@ -38,3 +67,52 @@ def registerDynamicModule(name, factory):
d
=
DynamicModule
(
name
,
factory
)
sys
.
modules
[
name
]
=
d
return
d
def
initializeDynamicModules
():
"""
Create erp5 module and its submodules
erp5.portal_type
holds portal type classes
erp5.temp_portal_type
holds portal type classes for temp objects
erp5.document
holds document classes that have no physical import path,
for example classes created through ClassTool that are in
$INSTANCE_HOME/Document
erp5.accessor_holder
holds accessor holders common to ZODB Property Sheets and Portal Types
erp5.accessor_holder.property_sheet
holds accessor holders of ZODB Property Sheets
erp5.accessor_holder.portal_type
holds accessors holders of Portal Types
"""
erp5
=
ModuleType
(
"erp5"
)
sys
.
modules
[
"erp5"
]
=
erp5
# Document classes without physical import path
erp5
.
document
=
ModuleType
(
"erp5.document"
)
sys
.
modules
[
"erp5.document"
]
=
erp5
.
document
# Portal types as classes
from
accessor_holder
import
AccessorHolderType
,
AccessorHolderModuleType
erp5
.
accessor_holder
=
AccessorHolderModuleType
(
"erp5.accessor_holder"
)
sys
.
modules
[
"erp5.accessor_holder"
]
=
erp5
.
accessor_holder
erp5
.
accessor_holder
.
property_sheet
=
\
AccessorHolderModuleType
(
"erp5.accessor_holder.property_sheet"
)
sys
.
modules
[
"erp5.accessor_holder.property_sheet"
]
=
\
erp5
.
accessor_holder
.
property_sheet
erp5
.
accessor_holder
.
portal_type
=
registerDynamicModule
(
'erp5.accessor_holder.portal_type'
,
AccessorHolderModuleType
)
from
lazy_class
import
generateLazyPortalTypeClass
erp5
.
portal_type
=
registerDynamicModule
(
'erp5.portal_type'
,
generateLazyPortalTypeClass
)
from
portal_type_class
import
loadTempPortalTypeClass
erp5
.
temp_portal_type
=
registerDynamicModule
(
'erp5.temp_portal_type'
,
loadTempPortalTypeClass
)
product/ERP5Type/dynamic/portal_type_class.py
View file @
6b765217
...
...
@@ -31,16 +31,13 @@ import sys
import
os
import
inspect
import
transaction
from
types
import
ModuleType
from
Products.ERP5Type.dynamic.dynamic_module
import
registerDynamicModule
from
Products.ERP5Type.mixin.temporary
import
TemporaryDocumentMixin
from
Products.ERP5Type.Base
import
Base
,
resetRegisteredWorkflowMethod
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type.Utils
import
setDefaultClassProperties
from
Products.ERP5Type
import
document_class_registry
,
mixin_class_registry
from
Products.ERP5Type.dynamic.accessor_holder
import
AccessorHolderModuleType
,
\
createAllAccessorHolderList
from
Products.ERP5Type.dynamic.accessor_holder
import
createAllAccessorHolderList
from
Products.ERP5Type.TransactionalVariable
import
TransactionalResource
from
zLOG
import
LOG
,
ERROR
,
INFO
,
WARNING
,
PANIC
...
...
@@ -250,63 +247,20 @@ def generatePortalTypeClass(site, portal_type_name):
interface_class_list
,
attribute_dict
)
from
lazy_class
import
generateLazyPortalTypeClass
def
initializeDynamicModules
():
def
loadTempPortalTypeClass
(
portal_type_name
):
"""
Create erp5 module and its submodules
erp5.portal_type
holds portal type classes
erp5.temp_portal_type
holds portal type classes for temp objects
erp5.document
holds document classes that have no physical import path,
for example classes created through ClassTool that are in
$INSTANCE_HOME/Document
erp5.accessor_holder
holds accessor holders common to ZODB Property Sheets and Portal Types
erp5.accessor_holder.property_sheet
holds accessor holders of ZODB Property Sheets
erp5.accessor_holder.portal_type
holds accessors holders of Portal Types
"""
erp5
=
ModuleType
(
"erp5"
)
sys
.
modules
[
"erp5"
]
=
erp5
erp5
.
document
=
ModuleType
(
"erp5.document"
)
sys
.
modules
[
"erp5.document"
]
=
erp5
.
document
erp5
.
accessor_holder
=
AccessorHolderModuleType
(
"erp5.accessor_holder"
)
sys
.
modules
[
"erp5.accessor_holder"
]
=
erp5
.
accessor_holder
erp5
.
accessor_holder
.
property_sheet
=
\
AccessorHolderModuleType
(
"erp5.accessor_holder.property_sheet"
)
sys
.
modules
[
"erp5.accessor_holder.property_sheet"
]
=
\
erp5
.
accessor_holder
.
property_sheet
erp5
.
accessor_holder
.
portal_type
=
registerDynamicModule
(
'erp5.accessor_holder.portal_type'
,
AccessorHolderModuleType
)
portal_type_container
=
registerDynamicModule
(
'erp5.portal_type'
,
generateLazyPortalTypeClass
)
Returns a class suitable for a temporary portal type
erp5
.
portal_type
=
portal_type_container
def
loadTempPortalTypeClass
(
portal_type_name
):
"""
Returns a class suitable for a temporary portal type
This class will in fact be a subclass of erp5.portal_type.xxx, which
means that loading an attribute on this temporary portal type loads
the lazily-loaded parent class, and that any changes on the parent
class will be reflected on the temporary objects.
"""
klass
=
getattr
(
portal_type_container
,
portal_type_name
)
return
type
(
"Temporary %s"
%
portal_type_name
,
(
TemporaryDocumentMixin
,
klass
),
{})
This class will in fact be a subclass of erp5.portal_type.xxx, which
means that loading an attribute on this temporary portal type loads
the lazily-loaded parent class, and that any changes on the parent
class will be reflected on the temporary objects.
"""
import
erp5.portal_type
klass
=
getattr
(
erp5
.
portal_type
,
portal_type_name
)
erp5
.
temp_portal_type
=
registerDynamicModule
(
'erp5.temp_portal_type'
,
loadTempPortalTypeClass
)
return
type
(
"Temporary %s"
%
portal_type_name
,
(
TemporaryDocumentMixin
,
klass
),
{}
)
last_sync
=
-
1
_bootstrapped
=
set
()
...
...
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