Commit 8fa51acb authored by Arnaud Fontaine's avatar Arnaud Fontaine

Implement migration of StringAttributeMatch from filesystem to ZODB.

parent 8e4db6c3
...@@ -66,4 +66,38 @@ class StringAttributeMatchConstraint(PropertyExistenceConstraint): ...@@ -66,4 +66,38 @@ class StringAttributeMatchConstraint(PropertyExistenceConstraint):
regular_expression=repr(regular_expression)))) regular_expression=repr(regular_expression))))
return error_list 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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment