[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator/Validators - BooleanValidator.py:1.1.2.2.2.1 DateTimeValidator.py:1.1.2.2.2.1 FileValidator.py:1.1.2.2.2.1 LinesValidator.py:1.1.2.4.2.1 MultiSelectionValidator.py:1.1.2.3.2.1 PatternValidator.py:1.1.2.2.2.1 SelectionValidator.py:1.1.2.2.2.1 StringBaseValidator.py:1.1.2.3.2.1 IValidator.py:NONE Validator.py:NONE

Stephan Richter srichter@cbu.edu
Fri, 1 Mar 2002 01:57:15 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator/Validators
In directory cvs.zope.org:/tmp/cvs-serv13304/Validators

Modified Files:
      Tag: srichter-OFS_Formulator-branch
	BooleanValidator.py DateTimeValidator.py FileValidator.py 
	LinesValidator.py MultiSelectionValidator.py 
	PatternValidator.py SelectionValidator.py 
	StringBaseValidator.py 
Removed Files:
      Tag: srichter-OFS_Formulator-branch
	IValidator.py Validator.py 
Log Message:
Checkin for new Formualtor layout. Much has changed since the initial
checkin:

- Both classes and instances of fields can be used as factory when creating
  views.

- Field: This object is simply a meta-data container for a piece of 
  information; for content objects these are usually its properties.

  Note: It is planned to have a CompositeField for more complex inputs, 
        such as dates.

- FieldViews are virtual objects; they are basically realized Widgets (or 
  Widgets in context)

- Validator: An object that validates data. Note that this object is 
  totally input/protocol-agnostic. Therefore the old concept of some of the
  Zope 2 Formulator validators is not applicable anymore.

- Widget: This is a generic component that is concerned about the 
  presentation of a field in a particular protocol. A difference to the 
  Zope 2 Formulator version is that the widget is also responsible of
  converting possible input-specific representation to a standard one. This
  is not yet fully implemented though.

- Form: A protocol-specific object that is concerned with the overall 
  representation of a form and its action.

- There is a Validator and Field Registry, since Fields and Validators can
  also be used independent of Formulator's goals. Fields should really 
  become the standard way to provide meta-data for properties.

Todo: (too much)

- I need to write a proper metaConfigure.py.

- Make a CompositeField.

- Create XUL Widgets.

- Clean up files.

- Finishing the conversion to the Zope 3 Formulator model.


=== Zope3/lib/python/Zope/App/Formulator/Validators/BooleanValidator.py 1.1.2.2 => 1.1.2.2.2.1 ===
 """
 
-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.2.2.1 ===
 """
 
-from DummyField import fields
 from StringValidator import StringValidator
 
-class DateTimeValidator(Validator):
+class DateTimeValidator(StringValidator):
 
-    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.'
+    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 +39,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
@@ -103,5 +72,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.2.2.1 ===
 """
 
-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.4.2.1 ===
 """
 
-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.3.2.1 ===
 """
 
-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.2.2.1 ===
 
 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.2.2.1 ===
 """
 
-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.3.2.1 ===
 """
 
-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 ===