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
0113a247
Commit
0113a247
authored
Mar 08, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop wrong properties.
parent
932ef611
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
17 deletions
+31
-17
product/ERP5Type/Constraint/PropertyTypeValidity.py
product/ERP5Type/Constraint/PropertyTypeValidity.py
+31
-17
No files found.
product/ERP5Type/Constraint/PropertyTypeValidity.py
View file @
0113a247
...
@@ -59,11 +59,15 @@ class PropertyTypeValidity(Constraint):
...
@@ -59,11 +59,15 @@ class PropertyTypeValidity(Constraint):
# Properties of type eg. "object" can hold anything
# Properties of type eg. "object" can hold anything
_permissive_type_list
=
(
'object'
,
'data'
)
_permissive_type_list
=
(
'object'
,
'data'
)
# Properties which shall be never set on object.
_wrong_property_id_list
=
(
'creation_date'
,
'modification_date'
)
_message_id_list
=
[
'message_unknown_type'
,
_message_id_list
=
[
'message_unknown_type'
,
'message_incorrect_type'
,
'message_incorrect_type'
,
'message_incorrect_type_fix_failed'
,
'message_incorrect_type_fix_failed'
,
'message_incorrect_type_fixed'
,
'message_incorrect_type_fixed'
,
'message_local_property_migrated'
]
'message_local_property_migrated'
,
'message_wrong_property_dropped'
]
message_unknown_type
=
"Attribute ${attribute_name} is defined with"
\
message_unknown_type
=
"Attribute ${attribute_name} is defined with"
\
" an unknown type ${type_name}"
" an unknown type ${type_name}"
...
@@ -75,6 +79,7 @@ class PropertyTypeValidity(Constraint):
...
@@ -75,6 +79,7 @@ class PropertyTypeValidity(Constraint):
message_incorrect_type_fixed
=
"Attribute ${attribute_name}"
\
message_incorrect_type_fixed
=
"Attribute ${attribute_name}"
\
" should be of type ${expected_type} but is of type ${actual_type} (Fixed)"
" should be of type ${expected_type} but is of type ${actual_type} (Fixed)"
message_local_property_migrated
=
"Property ${property_id} was migrated from local properties."
message_local_property_migrated
=
"Property ${property_id} was migrated from local properties."
message_wrong_property_dropped
=
"Wrong property ${property_id} dropped from object dict."
def
_checkConsistency
(
self
,
obj
,
fixit
=
0
):
def
_checkConsistency
(
self
,
obj
,
fixit
=
0
):
"""Check the object's consistency.
"""Check the object's consistency.
...
@@ -127,21 +132,30 @@ class PropertyTypeValidity(Constraint):
...
@@ -127,21 +132,30 @@ class PropertyTypeValidity(Constraint):
error_list
.
append
(
self
.
_generateError
(
obj
,
error_list
.
append
(
self
.
_generateError
(
obj
,
self
.
_getMessage
(
error_message
),
mapping
))
self
.
_getMessage
(
error_message
),
mapping
))
elif
fixit
and
property_id
in
\
elif
fixit
:
[
x
[
'id'
]
for
x
in
getattr
(
obj
,
'_local_properties'
,
())]:
if
property_id
in
\
# if this property was a local property and has been later added in a
[
x
[
'id'
]
for
x
in
getattr
(
obj
,
'_local_properties'
,
())]:
# property sheet, we want to remove it from _local_properties
# if this property was a local property and has been later added in a
# but as property key in local_properties does not have to match
# property sheet, we want to remove it from _local_properties
# property sheet key name, just all properties will be tried to be migrated
# but as property key in local_properties does not have to match
obj
.
_local_properties
=
tuple
([
x
for
x
in
obj
.
_local_properties
# property sheet key name, just all properties will be tried to be migrated
if
x
[
'id'
]
!=
property_id
])
obj
.
_local_properties
=
tuple
([
x
for
x
in
obj
.
_local_properties
oldvalue
=
getattr
(
obj
,
property_id
,
value
)
if
x
[
'id'
]
!=
property_id
])
if
oldvalue
!=
value
:
oldvalue
=
getattr
(
obj
,
property_id
,
value
)
obj
.
setProperty
(
property_id
,
oldvalue
)
if
oldvalue
!=
value
and
\
if
property_id
not
in
\
property_id
not
in
self
.
_wrong_property_id_list
:
[
x
[
'id'
]
for
x
in
getattr
(
obj
,
'_local_properties'
,
())]:
# drop totally low level properties
error_list
.
append
(
self
.
_generateError
(
obj
,
obj
.
setProperty
(
property_id
,
oldvalue
)
self
.
_getMessage
(
'message_local_property_migrated'
),
dict
(
if
property_id
not
in
\
property_id
=
property_id
)))
[
x
[
'id'
]
for
x
in
getattr
(
obj
,
'_local_properties'
,
())]:
error_list
.
append
(
self
.
_generateError
(
obj
,
self
.
_getMessage
(
'message_local_property_migrated'
),
dict
(
property_id
=
property_id
)))
if
property_id
in
self
.
_wrong_property_id_list
:
# drop totally low level properties
if
obj
.
__dict__
.
pop
(
property_id
,
None
)
is
not
None
:
error_list
.
append
(
self
.
_generateError
(
obj
,
self
.
_getMessage
(
'message_wrong_property_dropped'
),
dict
(
property_id
=
property_id
)))
return
error_list
return
error_list
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