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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eugene Shen
erp5
Commits
a526e1d9
Commit
a526e1d9
authored
Aug 31, 2012
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement migration of StringAttributeMatch from filesystem to ZODB.
parent
f448002f
Changes
1
Hide 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 @
a526e1d9
...
@@ -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
)
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