[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator/Validators - BooleanValidator.py:1.1.2.3 DateTimeValidator.py:1.1.2.3 FileValidator.py:1.1.2.3 LinesValidator.py:1.1.2.5 MultiSelectionValidator.py:1.1.2.4 PatternValidator.py:1.1.2.3 SelectionValidator.py:1.1.2.3 StringBaseValidator.py:1.1.2.4 IValidator.py:NONE Validator.py:NONE
Stephan Richter
srichter@cbu.edu
Wed, 27 Mar 2002 09:24:09 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator/Validators
In directory cvs.zope.org:/tmp/cvs-serv9605/Validators
Modified Files:
Tag: Zope-3x-branch
BooleanValidator.py DateTimeValidator.py FileValidator.py
LinesValidator.py MultiSelectionValidator.py
PatternValidator.py SelectionValidator.py
StringBaseValidator.py
Removed Files:
Tag: Zope-3x-branch
IValidator.py Validator.py
Log Message:
Major changes in Formulator (for details see
srichter-OFS_Formulator-branch checkins):
- Created simple registries for validators, fields and so on.
- Made Formulator compatible with new Publisher code
- Adjusted for better usibility.
Note: More to come as Formulaot is bring developed.
=== Zope3/lib/python/Zope/App/Formulator/Validators/BooleanValidator.py 1.1.2.2 => 1.1.2.3 ===
"""
-from Validator import Validator
+from Zope.App.Formulator.Validator import Validator
class BooleanValidator(Validator):
=== Zope3/lib/python/Zope/App/Formulator/Validators/DateTimeValidator.py 1.1.2.2 => 1.1.2.3 ===
"""
-from DummyField import fields
from StringValidator import StringValidator
+from Zope.Misc.DateTimeParse import parse
-class DateTimeValidator(Validator):
- property_names = Validator.property_names + ['required',
- 'start_datetime',
- 'end_datetime']
-
- required = fields.CheckBoxField('required',
- title='Required',
- description=(
- "Checked if the field is required; the user has to enter something "
- "in the field."),
- default=1)
-
- start_datetime = fields.DateTimeField('start_datetime',
- title="Start datetime",
- description=(
- "The date and time entered must be later than or equal to "
- "this date/time. If left empty, no check is performed."),
- default=None,
- input_style="text",
- required=0)
-
- end_datetime = fields.DateTimeField('end_datetime',
- title="End datetime",
- description=(
- "The date and time entered must be earlier than "
- "this date/time. If left empty, no check is performed."),
- default=None,
- input_style="text",
- required=0)
-
- message_names = Validator.message_names + ['required_not_found',
- 'not_datetime',
- 'datetime_out_of_range']
-
- required_not_found = 'Input is required but no input given.'
- not_datetime = 'You did not enter a valid date and time.'
- datetime_out_of_range = 'The date and time you entered were out of range.'
+class DateTimeValidator(StringValidator):
+
+ propertyNames = StringValidator.propertyNames + \
+ ['required', 'startDateTime', 'endDateTime']
+
+ requiredNotFound = 'Input is required but no input given.'
+ notDateTime = 'You did not enter a valid date and time.'
+ datetimeOutOfRange = 'The date and time you entered were out of range.'
def validate(self, field, key, REQUEST):
try:
@@ -70,7 +41,7 @@
hour = field.validate_sub_field('hour', REQUEST)
minute = field.validate_sub_field('minute', REQUEST)
except ValidationError:
- self.raise_error('not_datetime', field)
+ self.raiseError('not_datetime', field)
# handling of completely empty sub fields
if ((year == '' and month == '' and day == '') and
@@ -87,7 +58,7 @@
self.raise_error('not_datetime', field)
try:
- result = DateTime(int(year), int(month), int(day), hour, minute)
+ result = parse('%s/%s/%s %s:%s' %(year, month, day, hour, minute))
# ugh, a host of string based exceptions
except ('DateTimeError', 'Invalid Date Components', 'TimeError'):
self.raise_error('not_datetime', field)
@@ -103,5 +74,3 @@
self.raise_error('datetime_out_of_range', field)
return result
-
-DateTimeValidatorInstance = DateTimeValidator()
=== Zope3/lib/python/Zope/App/Formulator/Validators/FileValidator.py 1.1.2.2 => 1.1.2.3 ===
"""
-from Validator import Validator
+from Zope.App.Formulator.Validator import Validator
class FileValidator(Validator):
=== Zope3/lib/python/Zope/App/Formulator/Validators/LinesValidator.py 1.1.2.4 => 1.1.2.5 ===
"""
-from DummyField import fields
from StringBaseValidator import StringBaseValidator
@@ -28,7 +27,7 @@
maxLineLength = ""
maxLength = ""
- messagenames = StringBaseValidator.messagenames +\
+ messagenNames = StringBaseValidator.messageNames +\
['tooManylines', 'lineTooLong', 'tooLong']
tooManyLines = 'You entered too many lines.'
=== Zope3/lib/python/Zope/App/Formulator/Validators/MultiSelectionValidator.py 1.1.2.3 => 1.1.2.4 ===
"""
-from Validator import Validator
+from Zope.App.Formulator.Validator import Validator
from types import ListType
class MultiSelectionValidator(Validator):
=== Zope3/lib/python/Zope/App/Formulator/Validators/PatternValidator.py 1.1.2.2 => 1.1.2.3 ===
from StringValidator import StringValidator
+import PatternChecker
class PatternValidator(StringValidator):
@@ -37,7 +38,7 @@
def validate(self, field, value):
value = StringValidator.validate(self, field, value)
- if value == "" and not field.get_value('isRequired'):
+ if value == "" and not field.get_value('required'):
return value
value = self.checker.validate_value([field.get_value('pattern')],
=== Zope3/lib/python/Zope/App/Formulator/Validators/SelectionValidator.py 1.1.2.2 => 1.1.2.3 ===
"""
-from SelectionValidator import SelectionValidator
+from StringBaseValidator import StringBaseValidator
class SelectionValidator(StringBaseValidator):
=== Zope3/lib/python/Zope/App/Formulator/Validators/StringBaseValidator.py 1.1.2.3 => 1.1.2.4 ===
"""
-from Validator import Validator
+from Zope.App.Formulator.Validator import Validator
from types import StringType
=== Removed File Zope3/lib/python/Zope/App/Formulator/Validators/IValidator.py ===
=== Removed File Zope3/lib/python/Zope/App/Formulator/Validators/Validator.py ===