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
Levin Zimmermann
erp5
Commits
2fb1b3f1
Commit
2fb1b3f1
authored
Mar 09, 2012
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cosmetic: rename variables to more meaningful names in Component dynamic package.
parent
2a7ab878
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
34 deletions
+33
-34
product/ERP5Type/dynamic/component_package.py
product/ERP5Type/dynamic/component_package.py
+33
-34
No files found.
product/ERP5Type/dynamic/component_package.py
View file @
2fb1b3f1
...
...
@@ -191,34 +191,34 @@ class ComponentDynamicPackage(ModuleType):
properly in find_module().
"""
site
=
getSite
()
component_
name
=
fullname
[
len
(
self
.
_namespace_prefix
):]
if
component_
name
.
endswith
(
'_version'
):
version
=
component_
name
[:
-
self
.
__version_suffix_len
]
name
=
fullname
[
len
(
self
.
_namespace_prefix
):]
if
name
.
endswith
(
'_version'
):
version
=
name
[:
-
self
.
__version_suffix_len
]
return
(
version
in
site
.
getVersionPriorityNameList
()
and
self
.
_getVersionPackage
(
version
)
or
None
)
component_id
_alias
=
None
version_package_name
=
component_
name
[:
-
self
.
__version_suffix_len
]
if
'.'
in
component_
name
:
module_fullname
_alias
=
None
version_package_name
=
name
[:
-
self
.
__version_suffix_len
]
if
'.'
in
name
:
try
:
version
,
component_name
=
component_
name
.
split
(
'.'
)
version
,
name
=
name
.
split
(
'.'
)
version
=
version
[:
-
self
.
__version_suffix_len
]
except
ValueError
,
error
:
raise
ImportError
(
"%s: should be %s.VERSION.COMPONENT_REFERENCE (%s)"
%
\
(
fullname
,
self
.
_namespace
,
error
))
try
:
component
=
self
.
_registry_dict
[
component_
name
][
version
]
component
=
self
.
_registry_dict
[
name
][
version
]
except
KeyError
:
raise
ImportError
(
"%s: version %s of Component %s could not be found"
%
\
(
fullname
,
version
,
component_
name
))
(
fullname
,
version
,
name
))
else
:
try
:
component_version_dict
=
self
.
_registry_dict
[
component_
name
]
component_version_dict
=
self
.
_registry_dict
[
name
]
except
KeyError
:
raise
ImportError
(
"%s: Component %s could not be found"
%
(
fullname
,
component_
name
))
name
))
for
version
in
site
.
getVersionPriorityNameList
():
component
=
component_version_dict
.
get
(
version
)
...
...
@@ -226,55 +226,54 @@ class ComponentDynamicPackage(ModuleType):
break
else
:
raise
ImportError
(
"%s: no version of Component %s in Site priority"
%
\
(
fullname
,
component_
name
))
(
fullname
,
name
))
try
:
module
=
getattr
(
getattr
(
self
,
version
+
'_version'
),
component_
name
)
module
=
getattr
(
getattr
(
self
,
version
+
'_version'
),
name
)
except
AttributeError
:
pass
else
:
with
self
.
_load_module_lock
:
setattr
(
self
.
_getVersionPackage
(
version
),
component_
name
,
module
)
setattr
(
self
.
_getVersionPackage
(
version
),
name
,
module
)
return
module
component_id_alias
=
self
.
_namespace
+
'.'
+
component_
name
module_fullname_alias
=
self
.
_namespace
+
'.'
+
name
component_id
=
'%s.%s_version.%s'
%
(
self
.
_namespace
,
version
,
component_name
)
module_fullname
=
'%s.%s_version.%s'
%
(
self
.
_namespace
,
version
,
name
)
with
self
.
_load_module_lock
:
new_module
=
ModuleType
(
component_id
,
component
.
getDescription
())
module
=
ModuleType
(
module_fullname
,
component
.
getDescription
())
# The module *must* be in sys.modules before executing the code in case
# the module code imports (directly or indirectly) itself (see PEP 302)
sys
.
modules
[
component_id
]
=
new_
module
if
component_id
_alias
:
sys
.
modules
[
component_id_alias
]
=
new_
module
sys
.
modules
[
module_fullname
]
=
module
if
module_fullname
_alias
:
sys
.
modules
[
module_fullname_alias
]
=
module
# This must be set for imports at least (see PEP 302)
new_
module
.
__file__
=
'<'
+
component
.
getId
()
+
'>'
module
.
__file__
=
'<'
+
component
.
getId
()
+
'>'
try
:
component
.
load
(
new_
module
.
__dict__
,
validated_only
=
True
)
component
.
load
(
module
.
__dict__
,
validated_only
=
True
)
except
Exception
,
error
:
del
sys
.
modules
[
component_id
]
if
component_id
_alias
:
del
sys
.
modules
[
component_id
_alias
]
del
sys
.
modules
[
module_fullname
]
if
module_fullname
_alias
:
del
sys
.
modules
[
module_fullname
_alias
]
raise
ImportError
(
"%s: cannot load Component %s (%s)"
%
(
fullname
,
component_
name
,
name
,
error
))
new_
module
.
__path__
=
[]
new_
module
.
__loader__
=
self
new_module
.
__name__
=
component_id
module
.
__path__
=
[]
module
.
__loader__
=
self
module
.
__name__
=
module_fullname
setattr
(
self
.
_getVersionPackage
(
version
),
component_name
,
new_
module
)
if
component_id
_alias
:
setattr
(
self
,
component_name
,
new_
module
)
setattr
(
self
.
_getVersionPackage
(
version
),
name
,
module
)
if
module_fullname
_alias
:
setattr
(
self
,
name
,
module
)
return
new_
module
return
module
def
reset
(
self
,
sub_package
=
None
):
"""
...
...
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