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