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
Xavier Thompson
erp5
Commits
6c67fada
Commit
6c67fada
authored
Feb 23, 2012
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cosmetic: move checkConsistency error messages to class attributes.
parent
2388b36a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
product/ERP5Type/mixin/component.py
product/ERP5Type/mixin/component.py
+19
-11
No files found.
product/ERP5Type/mixin/component.py
View file @
6c67fada
...
@@ -143,6 +143,17 @@ class ComponentMixin(PropertyRecordableMixin, Base):
...
@@ -143,6 +143,17 @@ class ComponentMixin(PropertyRecordableMixin, Base):
'Reference'
,
'Reference'
,
'TextDocument'
)
'TextDocument'
)
_message_reference_not_set
=
"Reference must be set"
_message_invalid_reference
=
"Reference cannot end with '_version' or "
\
"start with '_' or be equal to find_module or load_module"
_message_version_not_set
=
"Version must be set"
_message_invalid_version
=
"Version cannot start with '_'"
_message_text_content_not_set
=
"No source code"
_message_invalid_text_content
=
"Source code: ${error_message}"
_message_text_content_syntax_error
=
"Syntax error in source code: "
\
"${error_message} (line: ${line_number}, column: ${column_number})"
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'checkConsistency'
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'checkConsistency'
)
def
checkConsistency
(
self
,
*
args
,
**
kw
):
def
checkConsistency
(
self
,
*
args
,
**
kw
):
"""
"""
...
@@ -156,7 +167,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
...
@@ -156,7 +167,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
error_list
.
append
(
error_list
.
append
(
ConsistencyMessage
(
self
,
ConsistencyMessage
(
self
,
object_relative_url
,
object_relative_url
,
message
=
"Reference must be set"
,
message
=
self
.
_message_reference_not_set
,
mapping
=
{}))
mapping
=
{}))
elif
(
reference
.
endswith
(
'_version'
)
or
elif
(
reference
.
endswith
(
'_version'
)
or
...
@@ -165,21 +176,19 @@ class ComponentMixin(PropertyRecordableMixin, Base):
...
@@ -165,21 +176,19 @@ class ComponentMixin(PropertyRecordableMixin, Base):
error_list
.
append
(
error_list
.
append
(
ConsistencyMessage
(
self
,
ConsistencyMessage
(
self
,
object_relative_url
,
object_relative_url
,
message
=
"Reference cannot end with '_version' or "
\
message
=
self
.
_message_invalid_reference
,
"start with '_' or be equal to find_module or "
\
"load_module"
,
mapping
=
{}))
mapping
=
{}))
version
=
self
.
getVersion
()
version
=
self
.
getVersion
()
if
not
version
:
if
not
version
:
error_list
.
append
(
ConsistencyMessage
(
self
,
error_list
.
append
(
ConsistencyMessage
(
self
,
object_relative_url
,
object_relative_url
,
message
=
"Version must be set"
,
message
=
self
.
_message_version_not_set
,
mapping
=
{}))
mapping
=
{}))
elif
version
[
0
]
==
'_'
:
elif
version
[
0
]
==
'_'
:
error_list
.
append
(
ConsistencyMessage
(
self
,
error_list
.
append
(
ConsistencyMessage
(
self
,
object_relative_url
,
object_relative_url
,
message
=
"Version cannot start with '_'"
,
message
=
self
.
_message_invalid_version
,
mapping
=
{}))
mapping
=
{}))
text_content
=
self
.
getTextContent
()
text_content
=
self
.
getTextContent
()
...
@@ -187,7 +196,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
...
@@ -187,7 +196,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
error_list
.
append
(
error_list
.
append
(
ConsistencyMessage
(
self
,
ConsistencyMessage
(
self
,
object_relative_url
=
object_relative_url
,
object_relative_url
=
object_relative_url
,
message
=
"No source code"
,
message
=
self
.
_message_text_content_not_set
,
mapping
=
{}))
mapping
=
{}))
else
:
else
:
message
=
None
message
=
None
...
@@ -198,12 +207,11 @@ class ComponentMixin(PropertyRecordableMixin, Base):
...
@@ -198,12 +207,11 @@ class ComponentMixin(PropertyRecordableMixin, Base):
line_number
=
e
.
lineno
,
line_number
=
e
.
lineno
,
column_number
=
e
.
offset
)
column_number
=
e
.
offset
)
message
=
"Syntax error in source code: ${error_message} "
\
message
=
self
.
_message_text_content_syntax_error
"(line: ${line_number}, column: ${column_number})"
except
Exception
,
e
:
except
Exception
,
e
:
mapping
=
dict
(
error_message
=
str
(
e
))
mapping
=
dict
(
error_message
=
str
(
e
))
message
=
"Source code: ${error_message}"
message
=
self
.
_message_invalid_text_content
if
message
:
if
message
:
error_list
.
append
(
error_list
.
append
(
...
@@ -240,7 +248,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
...
@@ -240,7 +248,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
"""
"""
current_workflow
=
self
.
workflow_history
[
'component_validation_workflow'
][
-
1
]
current_workflow
=
self
.
workflow_history
[
'component_validation_workflow'
][
-
1
]
return
[
str
(
error
.
getTranslatedMessage
())
return
[
str
(
error
.
getTranslatedMessage
())
for
error
in
current_workflow
[
'error_list'
]
]
for
error
in
current_workflow
.
get
(
'error_list'
,
[])
]
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'load'
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'load'
)
def
load
(
self
,
namespace_dict
=
{},
validated_only
=
False
,
text_content
=
None
):
def
load
(
self
,
namespace_dict
=
{},
validated_only
=
False
,
text_content
=
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