Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
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
Hamza
erp5-Boxiang
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
Show 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):
...
@@ -191,34 +191,34 @@ class ComponentDynamicPackage(ModuleType):
properly in find_module().
properly in find_module().
"""
"""
site
=
getSite
()
site
=
getSite
()
component_
name
=
fullname
[
len
(
self
.
_namespace_prefix
):]
name
=
fullname
[
len
(
self
.
_namespace_prefix
):]
if
component_
name
.
endswith
(
'_version'
):
if
name
.
endswith
(
'_version'
):
version
=
component_
name
[:
-
self
.
__version_suffix_len
]
version
=
name
[:
-
self
.
__version_suffix_len
]
return
(
version
in
site
.
getVersionPriorityNameList
()
and
return
(
version
in
site
.
getVersionPriorityNameList
()
and
self
.
_getVersionPackage
(
version
)
or
None
)
self
.
_getVersionPackage
(
version
)
or
None
)
component_id
_alias
=
None
module_fullname
_alias
=
None
version_package_name
=
component_
name
[:
-
self
.
__version_suffix_len
]
version_package_name
=
name
[:
-
self
.
__version_suffix_len
]
if
'.'
in
component_
name
:
if
'.'
in
name
:
try
:
try
:
version
,
component_name
=
component_
name
.
split
(
'.'
)
version
,
name
=
name
.
split
(
'.'
)
version
=
version
[:
-
self
.
__version_suffix_len
]
version
=
version
[:
-
self
.
__version_suffix_len
]
except
ValueError
,
error
:
except
ValueError
,
error
:
raise
ImportError
(
"%s: should be %s.VERSION.COMPONENT_REFERENCE (%s)"
%
\
raise
ImportError
(
"%s: should be %s.VERSION.COMPONENT_REFERENCE (%s)"
%
\
(
fullname
,
self
.
_namespace
,
error
))
(
fullname
,
self
.
_namespace
,
error
))
try
:
try
:
component
=
self
.
_registry_dict
[
component_
name
][
version
]
component
=
self
.
_registry_dict
[
name
][
version
]
except
KeyError
:
except
KeyError
:
raise
ImportError
(
"%s: version %s of Component %s could not be found"
%
\
raise
ImportError
(
"%s: version %s of Component %s could not be found"
%
\
(
fullname
,
version
,
component_
name
))
(
fullname
,
version
,
name
))
else
:
else
:
try
:
try
:
component_version_dict
=
self
.
_registry_dict
[
component_
name
]
component_version_dict
=
self
.
_registry_dict
[
name
]
except
KeyError
:
except
KeyError
:
raise
ImportError
(
"%s: Component %s could not be found"
%
(
fullname
,
raise
ImportError
(
"%s: Component %s could not be found"
%
(
fullname
,
component_
name
))
name
))
for
version
in
site
.
getVersionPriorityNameList
():
for
version
in
site
.
getVersionPriorityNameList
():
component
=
component_version_dict
.
get
(
version
)
component
=
component_version_dict
.
get
(
version
)
...
@@ -226,55 +226,54 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -226,55 +226,54 @@ class ComponentDynamicPackage(ModuleType):
break
break
else
:
else
:
raise
ImportError
(
"%s: no version of Component %s in Site priority"
%
\
raise
ImportError
(
"%s: no version of Component %s in Site priority"
%
\
(
fullname
,
component_
name
))
(
fullname
,
name
))
try
:
try
:
module
=
getattr
(
getattr
(
self
,
version
+
'_version'
),
component_
name
)
module
=
getattr
(
getattr
(
self
,
version
+
'_version'
),
name
)
except
AttributeError
:
except
AttributeError
:
pass
pass
else
:
else
:
with
self
.
_load_module_lock
:
with
self
.
_load_module_lock
:
setattr
(
self
.
_getVersionPackage
(
version
),
component_
name
,
module
)
setattr
(
self
.
_getVersionPackage
(
version
),
name
,
module
)
return
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
,
module_fullname
=
'%s.%s_version.%s'
%
(
self
.
_namespace
,
version
,
name
)
component_name
)
with
self
.
_load_module_lock
:
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 *must* be in sys.modules before executing the code in case
# the module code imports (directly or indirectly) itself (see PEP 302)
# the module code imports (directly or indirectly) itself (see PEP 302)
sys
.
modules
[
component_id
]
=
new_
module
sys
.
modules
[
module_fullname
]
=
module
if
component_id
_alias
:
if
module_fullname
_alias
:
sys
.
modules
[
component_id_alias
]
=
new_
module
sys
.
modules
[
module_fullname_alias
]
=
module
# This must be set for imports at least (see PEP 302)
# This must be set for imports at least (see PEP 302)
new_
module
.
__file__
=
'<'
+
component
.
getId
()
+
'>'
module
.
__file__
=
'<'
+
component
.
getId
()
+
'>'
try
:
try
:
component
.
load
(
new_
module
.
__dict__
,
validated_only
=
True
)
component
.
load
(
module
.
__dict__
,
validated_only
=
True
)
except
Exception
,
error
:
except
Exception
,
error
:
del
sys
.
modules
[
component_id
]
del
sys
.
modules
[
module_fullname
]
if
component_id
_alias
:
if
module_fullname
_alias
:
del
sys
.
modules
[
component_id
_alias
]
del
sys
.
modules
[
module_fullname
_alias
]
raise
ImportError
(
"%s: cannot load Component %s (%s)"
%
(
fullname
,
raise
ImportError
(
"%s: cannot load Component %s (%s)"
%
(
fullname
,
component_
name
,
name
,
error
))
error
))
new_
module
.
__path__
=
[]
module
.
__path__
=
[]
new_
module
.
__loader__
=
self
module
.
__loader__
=
self
new_module
.
__name__
=
component_id
module
.
__name__
=
module_fullname
setattr
(
self
.
_getVersionPackage
(
version
),
component_name
,
new_
module
)
setattr
(
self
.
_getVersionPackage
(
version
),
name
,
module
)
if
component_id
_alias
:
if
module_fullname
_alias
:
setattr
(
self
,
component_name
,
new_
module
)
setattr
(
self
,
name
,
module
)
return
new_
module
return
module
def
reset
(
self
,
sub_package
=
None
):
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