@@ 70-91 (lines=22) @@ | ||
67 | validation.register(IdentifierTypeAttributesValidator()) |
|
68 | ||
69 | ||
70 | class IdentifierValidator: |
|
71 | """some actual validation should go here. |
|
72 | I'm leaving this stub registered, but adding no extra validation. |
|
73 | """ |
|
74 | ||
75 | implements(IValidator) |
|
76 | name = "identifiervalidator" |
|
77 | ||
78 | def __call__(self, value, *args, **kwargs): |
|
79 | instance = kwargs['instance'] |
|
80 | request = instance.REQUEST |
|
81 | form = request.get('form', {}) |
|
82 | fieldname = kwargs['field'].getName() |
|
83 | form_value = form.get(fieldname, False) |
|
84 | if form_value is False: |
|
85 | # not required... |
|
86 | return True |
|
87 | if value == instance.get(fieldname): |
|
88 | # no change. |
|
89 | return True |
|
90 | ||
91 | return True |
|
92 | ||
93 | ||
94 | validation.register(IdentifierValidator()) |
|
@@ 43-64 (lines=22) @@ | ||
40 | from zope.interface import implements |
|
41 | ||
42 | ||
43 | class IdentifierTypeAttributesValidator: |
|
44 | """Validate IdentifierTypeAttributes to ensure that attributes are |
|
45 | not duplicated. |
|
46 | """ |
|
47 | ||
48 | implements(IValidator) |
|
49 | name = "identifiertypeattributesvalidator" |
|
50 | ||
51 | def __call__(self, value, *args, **kwargs): |
|
52 | instance = kwargs['instance'] |
|
53 | request = instance.REQUEST |
|
54 | form = request.get('form', {}) |
|
55 | fieldname = kwargs['field'].getName() |
|
56 | form_value = form.get(fieldname, False) |
|
57 | if form_value is False: |
|
58 | # not required... |
|
59 | return True |
|
60 | if value == instance.get(fieldname): |
|
61 | # no change. |
|
62 | return True |
|
63 | ||
64 | return True |
|
65 | ||
66 | ||
67 | validation.register(IdentifierTypeAttributesValidator()) |