| Revision 5,
668 bytes
checked in by nigel.sim, 5 years ago
(diff) |
|
|
| Line | |
|---|
| 1 | # |
|---|
| 2 | # ShoeBox |
|---|
| 3 | # A start product for Plone - ShoeBox |
|---|
| 4 | # |
|---|
| 5 | # ShoeBox.py |
|---|
| 6 | # Validation |
|---|
| 7 | # |
|---|
| 8 | # Author: Christian Koller <admin@iecw.net> |
|---|
| 9 | # |
|---|
| 10 | # Released under GNU GPL v2 or later |
|---|
| 11 | # |
|---|
| 12 | |
|---|
| 13 | from Products.validation.interfaces import ivalidator |
|---|
| 14 | |
|---|
| 15 | ## |
|---|
| 16 | ## Tests if the value is one of the allowed values |
|---|
| 17 | ## |
|---|
| 18 | class AllowedUrl: |
|---|
| 19 | __implements__ = (ivalidator,) |
|---|
| 20 | |
|---|
| 21 | def __init__(self, name, allowed): |
|---|
| 22 | self.name = name |
|---|
| 23 | self.allowed = allowed |
|---|
| 24 | |
|---|
| 25 | def __call__(self, value, *args, **kwargs): |
|---|
| 26 | |
|---|
| 27 | if self.allowed.count(value) > 0: |
|---|
| 28 | return True |
|---|
| 29 | else: |
|---|
| 30 | return (""" |
|---|
| 31 | Error: '%(value)s' is not a allowed access mode. Use one off: %(allowed)s. |
|---|
| 32 | """ % {'value': value, 'allowed': self.allowed}) |
|---|
Note: See
TracBrowser
for help on using the repository browser.