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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
c2ce3ba0
Commit
c2ce3ba0
authored
Jan 22, 2014
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZODB Components: Log error *and* traceback for both Extension and Document Components.
parent
cb631f83
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
21 deletions
+38
-21
product/ERP5Type/dynamic/component_package.py
product/ERP5Type/dynamic/component_package.py
+26
-0
product/ERP5Type/dynamic/portal_type_class.py
product/ERP5Type/dynamic/portal_type_class.py
+7
-14
product/ERP5Type/patches/ExternalMethod.py
product/ERP5Type/patches/ExternalMethod.py
+5
-7
No files found.
product/ERP5Type/dynamic/component_package.py
View file @
c2ce3ba0
...
@@ -407,6 +407,32 @@ class ComponentDynamicPackage(ModuleType):
...
@@ -407,6 +407,32 @@ class ComponentDynamicPackage(ModuleType):
with
aq_method_lock
:
with
aq_method_lock
:
return
self
.
__load_module
(
fullname
)
return
self
.
__load_module
(
fullname
)
def
find_load_module
(
self
,
name
):
"""
Find and load a Component module.
When FS fallback is required (mainly for Document and Extension), this
should be used over a plain import to distinguish a document not available
as ZODB Component to an error in a Component, especially because in the
latter case only ImportError can be raised (PEP-302).
For example: if a Component tries to import another Component module but
the latter has been disabled and there is a fallback on the filesystem, a
plain import would hide the real error, instead log it...
"""
fullname
=
self
.
_namespace
+
'.'
+
name
loader
=
self
.
find_module
(
fullname
)
if
loader
is
not
None
:
try
:
return
loader
.
load_module
(
fullname
)
except
ImportError
,
e
:
import
traceback
LOG
(
"ERP5Type.dynamic"
,
WARNING
,
"Could not load Component module '%s'
\
n
%s"
%
(
fullname
,
traceback
.
format_exc
()))
return
None
def
reset
(
self
,
sub_package
=
None
):
def
reset
(
self
,
sub_package
=
None
):
"""
"""
Reset the content of the current package and its version package as well
Reset the content of the current package and its version package as well
...
...
product/ERP5Type/dynamic/portal_type_class.py
View file @
c2ce3ba0
...
@@ -195,22 +195,15 @@ def generatePortalTypeClass(site, portal_type_name):
...
@@ -195,22 +195,15 @@ def generatePortalTypeClass(site, portal_type_name):
if
not
(
type_class_namespace
.
startswith
(
'Products.ERP5Type'
)
or
if
not
(
type_class_namespace
.
startswith
(
'Products.ERP5Type'
)
or
portal_type_name
in
core_portal_type_class_dict
):
portal_type_name
in
core_portal_type_class_dict
):
import
erp5.component.document
import
erp5.component.document
module_fullname
=
'erp5.component.document.'
+
type_class
module
=
erp5
.
component
.
document
.
find_load_module
(
type_class
)
module_loader
=
erp5
.
component
.
document
.
find_module
(
module_fullname
)
if
module
is
not
None
:
if
module_loader
is
not
None
:
try
:
try
:
module
=
module_loader
.
load_module
(
module_fullname
)
klass
=
getattr
(
module
,
type_class
)
except
ImportError
,
e
:
except
AttributeError
:
LOG
(
"ERP5Type.dynamic"
,
WARNING
,
LOG
(
"ERP5Type.dynamic"
,
WARNING
,
"Could not load Component module '%s': %s"
%
(
module_fullname
,
e
))
"Could not get class '%s' in Component module '%s'"
%
\
else
:
(
type_class
,
try
:
module_fullname
))
klass
=
getattr
(
module
,
type_class
)
except
AttributeError
:
LOG
(
"ERP5Type.dynamic"
,
WARNING
,
"Could not get class '%s' in Component module '%s'"
%
\
(
type_class
,
module_fullname
))
if
klass
is
None
:
if
klass
is
None
:
type_class_path
=
document_class_registry
.
get
(
type_class
)
type_class_path
=
document_class_registry
.
get
(
type_class
)
...
...
product/ERP5Type/patches/ExternalMethod.py
View file @
c2ce3ba0
...
@@ -81,11 +81,11 @@ if 1:
...
@@ -81,11 +81,11 @@ if 1:
- fix magic "self" argument when positional arguments get their values
- fix magic "self" argument when positional arguments get their values
from kw.
from kw.
"""
"""
try
:
import
erp5.component.extension
component_module
=
__import__
(
'erp5.component.extension.'
+
self
.
_module
,
component_module
=
erp5
.
component
.
extension
.
find_load_module
(
self
.
_module
)
fromlist
=
[
'erp5.component.extension'
],
if
component_module
is
not
None
:
level
=
0
)
f
=
getattr
(
component_module
,
self
.
_function
)
e
xcept
ImportError
:
e
lse
:
import
Globals
# for data
import
Globals
# for data
filePath
=
self
.
filepath
()
filePath
=
self
.
filepath
()
...
@@ -103,8 +103,6 @@ if 1:
...
@@ -103,8 +103,6 @@ if 1:
self
.
reloadIfChanged
()
self
.
reloadIfChanged
()
f
=
None
f
=
None
else
:
f
=
getattr
(
component_module
,
self
.
_function
)
_v_f
=
getattr
(
self
,
'_v_f'
,
None
)
_v_f
=
getattr
(
self
,
'_v_f'
,
None
)
if
not
_v_f
or
(
f
and
f
is
not
_v_f
):
if
not
_v_f
or
(
f
and
f
is
not
_v_f
):
...
...
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