Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Sven Franck
erp5
Commits
4acbcfe9
Commit
4acbcfe9
authored
12 years ago
by
Arnaud Fontaine
Browse files
Options
Download
Email Patches
Plain Diff
Implement migration of StringAttributeMatch from filesystem to ZODB.
parent
38d728d2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
1 deletion
+35
-1
product/ERP5/Document/StringAttributeMatchConstraint.py
product/ERP5/Document/StringAttributeMatchConstraint.py
+35
-1
No files found.
product/ERP5/Document/StringAttributeMatchConstraint.py
View file @
4acbcfe9
...
...
@@ -66,4 +66,38 @@ class StringAttributeMatchConstraint(PropertyExistenceConstraint):
regular_expression
=
repr
(
regular_expression
))))
return
error_list
_message_id_tuple
=
(
'message_attribute_does_not_match'
,)
_message_id_tuple
=
PropertyExistenceConstraint
.
_message_id_tuple
+
\
(
'message_attribute_does_not_match'
,)
@
staticmethod
def
_convertFromFilesystemDefinition
(
**
property_dict
):
"""
@see ERP5Type.mixin.constraint.ConstraintMixin._convertFromFilesystemDefinition
One constraint per regular expression and containing one or several
properties is created. Filesystem definition example:
{ 'id' : 'title_not_empty',
'description' : 'Title must be defined',
'type' : 'StringAttributeMatch',
'title' : '^[^ ]'
}
"""
property_list
=
property_dict
.
keys
()
regex_list
=
property_dict
.
values
()
regex_list_len
=
len
(
regex_list
)
seen_property_set
=
set
()
for
property_index
,
property_id
in
enumerate
(
property_list
):
if
property_id
in
seen_property_set
:
continue
constraint_property_list
=
[
property_id
]
constraint_regex
=
regex_list
[
property_index
]
property_index
+=
1
for
regex_index
,
regex
in
enumerate
(
regex_list
[
property_index
:],
property_index
):
if
constraint_regex
==
regex
:
regex_property_id
=
property_list
[
regex_index
]
constraint_property_list
.
append
(
regex_property_id
)
seen_property_set
.
add
(
regex_property_id
)
yield
dict
(
constraint_property_list
=
constraint_property_list
,
regular_expression
=
constraint_regex
)
This diff is collapsed.
Click to expand it.
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