[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator/Validators - BooleanValidator.py:1.1.2.1 BooleanValidator.pyc:1.1.2.1 DateTimeValidator.py:1.1.2.1 EmailValidator.py:1.1.2.1 EmailValidator.pyc:1.1.2.1 FileValidator.py:1.1.2.1 FileValidator.pyc:1.1.2.1 FloatValidator.py:1.1.2.1 FloatValidator.pyc:1.1.2.1 IValidator.py:1.1.2.1 IValidator.pyc:1.1.2.1 IntegerValidator.py:1.1.2.1 IntegerValidator.pyc:1.1.2.1 LinesValidator.py:1.1.2.1 LinkValidator.py:1.1.2.1 ListLinesValidator.py:1.1.2.1 MultiSelectionValidator.py:1.1.2.1 PatternChecker.py:1.1.2.1 PatternValidator.py:1.1.2.1 SelectionValidator.py:1.1.2.1 StringBaseValidator.py:1.1.2.1 StringBaseValidator.pyc:1.1.2.1 StringValidator.py:1.1.2.1 StringValidator.pyc:1.1.2.1 TextValidator.py:1.1.2.1 Validator.py:1.1.2.1 Validator.pyc:1.1.2.1 __init__.py:1.1.2.1 __init__.pyc:1.1.2.1

Stephan Richter srichter@cbu.edu
Fri, 25 Jan 2002 09:11:13 -0500


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

Added Files:
      Tag: Zope-3x-branch
	BooleanValidator.py BooleanValidator.pyc DateTimeValidator.py 
	EmailValidator.py EmailValidator.pyc FileValidator.py 
	FileValidator.pyc FloatValidator.py FloatValidator.pyc 
	IValidator.py IValidator.pyc IntegerValidator.py 
	IntegerValidator.pyc LinesValidator.py LinkValidator.py 
	ListLinesValidator.py MultiSelectionValidator.py 
	PatternChecker.py PatternValidator.py SelectionValidator.py 
	StringBaseValidator.py StringBaseValidator.pyc 
	StringValidator.py StringValidator.pyc TextValidator.py 
	Validator.py Validator.pyc __init__.py __init__.pyc 
Log Message:
- Initial check-in of the Formulator code
- Even though not everything works (specifically the widgets are in bad 
  shape), I am checking that stuff in, so that Jim, Martijn F. and I can
  better work together.
- The FileEdit screen (which will be checked in in a minute) uses already
  formulator.
- The validators are closed to finished.
- I think we have to rethink some of the design, simply because it is too
  hard right now to create a field and a view for a property, even though
  I provided already some handy methods. However Formulator does not 
  depend on Property-driven content objects.
- Please contact me (srichter@cbu.edu) or the Zope3 mailining list to 
  discuss issues and design.


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/BooleanValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: BooleanValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from Validator import Validator

class BooleanValidator(Validator):

    __implements__ = Validator.__implements__

    
    def validate(self, field, value):

        if value in ['t', 1]:
            return 1

        if value in ['f', 0, '', None]:
            return 0

        # XXX Should raise some sort of error


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/BooleanValidator.pyc ===
-í
‹bQ<c       s9     d  Z    d k l Z  d e f d „  ƒ  YZ d S(   s   

Revision information: $Id: BooleanValidator.pyc,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
(   s	   Validators   BooleanValidatorc      s     e  i Z  d „  Z RS(   Nc    sO     | d d g j o  d Sn  | d d d t g j o  d Sn d  S(   Ns   ti   s   fi    s    (   s   values   None(   s   selfs   fields   value(    (    sH   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/BooleanValidator.pys   validate s   (   s	   Validators   __implements__s   validate(    (    (    sH   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/BooleanValidator.pys   BooleanValidator s   N(   s   __doc__s	   Validators   BooleanValidator(   s	   Validators   BooleanValidator(    (    sH   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/BooleanValidator.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/DateTimeValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: DateTimeValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from DummyField import fields
from StringValidator import StringValidator

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.'
    
    def validate(self, field, key, REQUEST):    
        try:
            year = field.validate_sub_field('year', REQUEST)
            month = field.validate_sub_field('month', REQUEST)
            day = field.validate_sub_field('day', REQUEST)
            
            if field.get_value('date_only'):
                hour = 0
                minute = 0
            else:
                hour = field.validate_sub_field('hour', REQUEST)
                minute = field.validate_sub_field('minute', REQUEST)
        except ValidationError:
            self.raise_error('not_datetime', field)

        # handling of completely empty sub fields
        if ((year == '' and month == '' and day == '') and
            (field.get_value('date_only') or (hour == '' and minute == ''))): 
            if field.get_value('required'):
                self.raise_error('required_not_found', field)
            else:
                # field is not required, return None for no entry
                return None
        # handling of partially empty sub fields; invalid datetime
        if ((year == '' or month == '' or day == '') or
            (not field.get_value('date_only') and
             (hour == '' or minute == ''))):
            self.raise_error('not_datetime', field)

        try:
            result = DateTime(int(year), int(month), int(day), hour, minute)
        # ugh, a host of string based exceptions
        except ('DateTimeError', 'Invalid Date Components', 'TimeError'):
            self.raise_error('not_datetime', field)

        # check if things are within range
        start_datetime = field.get_value('start_datetime')
        if (start_datetime is not None and
            result < start_datetime):
            self.raise_error('datetime_out_of_range', field)
        end_datetime = field.get_value('end_datetime')
        if (end_datetime is not None and
            result >= end_datetime):
            self.raise_error('datetime_out_of_range', field)

        return result
    
DateTimeValidatorInstance = DateTimeValidator()


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/EmailValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: EmailValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

import re
from StringValidator import StringValidator

class EmailValidator(StringValidator):

    __implements__ = StringValidator.__implements__

    messageNames = StringValidator.messageNames + ['notEmail']

    notEmail = 'You did not enter an email address.'

    # contributed, I don't pretend to understand this..
    pattern = re.compile("^([0-9a-z_&.+-]+!)*[0-9a-z_&.+-]+"
                         "@(([0-9a-z]([0-9a-z-]*[0-9a-z])?\.)+"
                         "[a-z]{2,3}|([0-9]{1,3}\.){3}[0-9]{1,3})$")
    
    def validate(self, field, value):
        value = StringValidator.validate(self, field, value)

        if value == "" and not field.getValue('isRequired'):
            return value

        if self.pattern.search(value.lower()) == None:
            self.raiseError('notEmail', field)
        return value


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/EmailValidator.pyc ===
-í
¨bQ<c       sE     d  Z    d k Z  d k l Z  d e f d „  ƒ  YZ d S(   s   

Revision information: $Id: EmailValidator.pyc,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
N(   s   StringValidators   EmailValidatorc      sK     e  i Z  e  i d g Z  d Z  e i d ƒ Z " d „  Z RS(   Ns   notEmails#   You did not enter an email address.sm   ^([0-9a-z_&.+-]+!)*[0-9a-z_&.+-]+@(([0-9a-z]([0-9a-z-]*[0-9a-z])?\.)+[a-z]{2,3}|([0-9]{1,3}\.){3}[0-9]{1,3})$c    s‹   " # t  i |  | | ƒ } % | d j o | i d ƒ o & | Sn ( |  i i | i ƒ  ƒ t	 j o ) |  i
 d | ƒ n * | Sd  S(   Ns    s
   isRequireds   notEmail(   s   StringValidators   validates   selfs   fields   values   getValues   patterns   searchs   lowers   Nones
   raiseError(   s   selfs   fields   value(    (    sF   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/EmailValidator.pys   validate" s   !"(   s   StringValidators   __implements__s   messageNamess   notEmails   res   compiles   patterns   validate(    (    (    sF   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/EmailValidator.pys   EmailValidator s
   	(   s   __doc__s   res   StringValidators   EmailValidator(   s   StringValidators   res   EmailValidator(    (    sF   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/EmailValidator.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/FileValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: FileValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from Validator import Validator


class FileValidator(Validator):

    __implements__ = Validator.__implements__

    def validate(self, field, value):
        return value



=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/FileValidator.pyc ===
-í
òbQ<c       s9     d  Z    d k l Z  d e f d „  ƒ  YZ d S(   s   

Revision information: $Id: FileValidator.pyc,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
(   s	   Validators
   FileValidatorc      s     e  i Z  d „  Z RS(   Nc    s     | Sd  S(   N(   s   value(   s   selfs   fields   value(    (    sE   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/FileValidator.pys   validate s   (   s	   Validators   __implements__s   validate(    (    (    sE   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/FileValidator.pys
   FileValidator s   N(   s   __doc__s	   Validators
   FileValidator(   s
   FileValidators	   Validator(    (    sE   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/FileValidator.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/FloatValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: FloatValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from StringBaseValidator import StringBaseValidator


class FloatValidator(StringBaseValidator):

    __implements__ = StringBaseValidator.__implements__

    messageNames = StringBaseValidator.messageNames + ['notFloat']
    notFloat = "You did not enter a floating point number."


    def validate(self, field, value):
        value = StringBaseValidator.validate(self, field, value)
        if value == "" and not field.getValue('isRequired'):
            return value

        try:
            value = float(value)
        except ValueError:
            self.raiseError('notFloat', field)
        return value


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/FloatValidator.pyc ===
-í
cQ<c       s9     d  Z    d k l Z  d e f d „  ƒ  YZ d S(   s   

Revision information: $Id: FloatValidator.pyc,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
(   s   StringBaseValidators   FloatValidatorc      s9     e  i Z  e  i d g Z  d Z  d „  Z RS(   Ns   notFloats*   You did not enter a floating point number.c    s”     t  i |  | | ƒ }  | d j o | i d ƒ o   | Sn " y # t | ƒ } Wn) $ t j
 o % |  i d | ƒ n X& | Sd  S(   Ns    s
   isRequireds   notFloat(	   s   StringBaseValidators   validates   selfs   fields   values   getValues   floats
   ValueErrors
   raiseError(   s   selfs   fields   value(    (    sF   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/FloatValidator.pys   validate s   !(   s   StringBaseValidators   __implements__s   messageNamess   notFloats   validate(    (    (    sF   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/FloatValidator.pys   FloatValidator s   	N(   s   __doc__s   StringBaseValidators   FloatValidator(   s   StringBaseValidators   FloatValidator(    (    sF   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/FloatValidator.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/IValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: IValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from Interface import Interface

class IValidator(Interface):
    """A field validator provides the functionality to verify the
       input data on the server. 

       This class will be initialized as a singleton.
    """

    def validate(field, value):
        """Validate the value, knowing the field.
        """

    def raiseError(errorKey, field):
        """Raises the error, if the validation fails.
        """


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/IValidator.pyc ===
-í
1cQ<c       s9     d  Z    d k l Z  d e f d „  ƒ  YZ d S(   s   

Revision information: $Id: IValidator.pyc,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
(   s	   Interfaces
   IValidatorc      s&    d  Z    d „  Z  d „  Z RS(   s˜   A field validator provides the functionality to verify the
       input data on the server. 

       This class will be initialized as a singleton.
    c    s
     d S(   s/   Validate the value, knowing the field.
        N(    (   s   fields   value(    (    sB   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/IValidator.pys   validate s   c    s
    ! d S(   s3   Raises the error, if the validation fails.
        N(    (   s   errorKeys   field(    (    sB   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/IValidator.pys
   raiseError s   (   s   __doc__s   validates
   raiseError(    (    (    sB   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/IValidator.pys
   IValidator s   	N(   s   __doc__s	   Interfaces
   IValidator(   s	   Interfaces
   IValidator(    (    sB   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/IValidator.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/IntegerValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: IntegerValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from StringBaseValidator import StringBaseValidator

class IntegerValidator(StringBaseValidator):
    """ """

    __implements__ = StringBaseValidator.__implements__

    propertyNames = StringBaseValidator.propertyNames +\
                    ['start', 'end']

    start = ""
    end = ""
    messageNames = StringBaseValidator.messageNames +\
                   ['notInteger', 'integerOutOfRange']

    notInteger = 'You did not enter an integer.'
    integerOutOfRange = 'The integer you entered was out of range.'

    def validate(self, field, value):
        value = StringBaseValidator.validate(self, field, value)
        
        # we need to add this check again
        if value == "" and not field.getValue('isRequired'):
            return value

        try:
            value = int(value)
        except ValueError:
            self.raiseError('notInteger', field)

        if self.start != "" and value < self.start:
            self.raiseError('integerOutOfRange', field)
        if self.end != "" and value >= self.end:
            self.raiseError('integerOutOfRange', field)
        return value


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/IntegerValidator.pyc ===
-í
OcQ<c       s9     d  Z    d k l Z  d e f d „  ƒ  YZ d S(   s   

Revision information: $Id: IntegerValidator.pyc,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
(   s   StringBaseValidators   IntegerValidatorc      sv    d  Z    e i Z  e i d d g Z  d Z  d Z  e i d d g Z ! d Z " d Z $ d „  Z	 RS(	   s    s   starts   ends    s
   notIntegers   integerOutOfRanges   You did not enter an integer.s)   The integer you entered was out of range.c    s  $ % t  i |  | | ƒ } ( | d j o | i d ƒ o ) | Sn + y , t | ƒ } Wn) - t j
 o . |  i d | ƒ n X0 |  i	 d j o
 | |  i	 j  o 1 |  i d | ƒ n 2 |  i
 d j o
 | |  i
 j o 3 |  i d | ƒ n 4 | Sd  S(   Ns    s
   isRequireds
   notIntegers   integerOutOfRange(   s   StringBaseValidators   validates   selfs   fields   values   getValues   ints
   ValueErrors
   raiseErrors   starts   end(   s   selfs   fields   value(    (    sH   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/IntegerValidator.pys   validate$ s   !##(
   s   __doc__s   StringBaseValidators   __implements__s
   propertyNamess   starts   ends   messageNamess
   notIntegers   integerOutOfRanges   validate(    (    (    sH   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/IntegerValidator.pys   IntegerValidator s   					N(   s   __doc__s   StringBaseValidators   IntegerValidator(   s   IntegerValidators   StringBaseValidator(    (    sH   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/IntegerValidator.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/LinesValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: LinesValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from DummyField import fields
from StringBaseValidator import StringBaseValidator


class LinesValidator(StringBaseValidator):

    propertyNames = StringBaseValidator.propertyNames +\
                     ['maxLines', 'maxLineLength', 'maxLength']

    maxLines = ""
    maxLineLength = ""
    maxLength = 
    
    messagenames = StringBaseValidator.messagenames +\
                   ['tooManylines', 'lineTooLong', 'tooLong']

    tooManyLines = 'You entered too many lines.'
    lineTooLong = 'A line was too long.'
    tooLong = 'You entered too many characters.'

    
    def validate(self, field, value):
        value = StringBaseValidator.validate(self, field, value)
        # we need to add this check again
        if value == "" and not field.get_value('required'):
            return []
        
        # check whether the entire input is too long
        maxLength = field.get_value('maxLength') or 0
        if maxLength and len(value) > maxLength:
            self.raise_error('tooLong', field)
        # split input into separate lines
        lines = string.split(value, "\n")

        # check whether we have too many lines
        maxLines = field.get_value('maxLines') or 0
        if maxLines and len(lines) > maxLines:
            self.raise_error('tooManyLines', field)

        # strip extraneous data from lines and check whether each line is
        # short enough
        maxLineLength = field.get_value('maxLineLength') or 0
        result = []
        for line in lines:
            line = string.strip(line)
            if maxLineLength and len(line) > maxLineLength:
                self.raise_error('lineTooLong', field)
            result.append(line)
            
        return result


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/LinkValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: LinkValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from StringValidator import StringValidator


class LinkHelper:
    """A helper class to check if links are openable.
    """
    status = 0

    def __init__(self, link):
        self.link = link
        
    def open(self):
        try:
            urlopen(self.link)
        except:
            # all errors will definitely result in a failure
            pass
        else:
            # FIXME: would like to check for 404 errors and such?
            self.status = 1


class LinkValidator(StringValidator):
    """ """

    propertyNames = StringValidator.propertyNames +\
                     ['checkLink', 'checkTimeout', 'linkType']
    
    checkLink = 0
    checkTimeout = 7.0
    linkType = "external"
    
    messageNames = StringValidator.messageNames + ['notLink']
    
    notLink = 'The specified link is broken.'
    
    def validate(self, field, value):
        value = StringValidator.validate(self, field, value)
        if value == "" and not field.get_value('required'):
            return value
        
        linkType = field.get_value('linkType')
        if linkType == 'internal':
            value = urljoin(REQUEST['BASE0'], value)
        elif linkType == 'relative':
            value = urljoin(REQUEST['URL1'], value)
        # otherwise must be external

        # FIXME: should try regular expression to do some more checking here?
        
        # if we don't need to check the link, we're done now
        if not field.get_value('checkLink'):
            return value

        # check whether we can open the link
        link = LinkHelper(value)
        thread = Thread(target=link.open)
        thread.start()
        thread.join(field.get_value('checkTimeout'))
        del thread
        if not link.status:
            self.raise_error('notLink', field)
            
        return value


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/ListLinesValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: ListLinesValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from LinesValidator import LinesValidator

class ListLinesValidator(LinesValidator):
    """A validator that can deal with lines that have a | separator
    in them to split between text and value of list items.
    """

    __implements__ = LinesValidator.__implements__
    
    def validate(self, value):
        
        value = Validator.LinesValidator.validate(value)
        result = []
        for line in value:
            elements = string.split(line, "|")
            if len(elements) >= 2:
                text, value = elements[:2]
            else:
                text = line
                value = line
            text = string.strip(text)
            value = string.strip(value)
            result.append((text, value))
        return result


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/MultiSelectionValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: MultiSelectionValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from Validator import Validator


class MultiSelectionValidator(Validator):
    """ """
    
    __implements__ = Validator.__implements__

    propertyNames = Validator.propertyNames + ['required']

    required = 1

    messageNames = Validator.messageNames + ['requiredNotFound',
                                             'unknownSelection']
    
    requiredNotFound = 'Input is required but no input given.'
    unknownSelection = 'You selected an item that was not in the list.'

    
    def validate(self, field, value):
        values = value
        # NOTE: a hack to deal with single item selections
        if type(values) is not type([]):
            # put whatever we got in a list
            values = [values]

        # if we selected nothing and entry is required, give error, otherwise
        # give entry list
        if len(values) == 0:
            if field.get_value('isRequired'):
                self.raise_error('requiredNotFound', field)
            else:
                return values
            
        # create a dictionary of possible values
        value_dict = {}
        for item in field.get_value('items'):
            try:
                item_text, item_value = item
            except ValueError:
                item_text = item
                item_value = item
            value_dict[item_value] = 0
        # check whether all values are in dictionary
        result = []
        for value in values:
            # FIXME: hack to accept int values as well
            try:
                int_value = int(value)
            except ValueError:
                int_value = None
            if int_value is not None and value_dict.has_key(int_value):
                result.append(int_value)
                continue
            if value_dict.has_key(value):
                result.append(value)
                continue
            self.raise_error('unknownSelection', field)
        # everything checks out
        return result


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/PatternChecker.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: PatternChecker.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""
import re

# Symbols that are used to represent groups of characters

NUMBERSYMBOL  = 'd'             # 0-9
CHARSYMBOL    = 'e'             # a-zA-Z
NUMCHARSYMBOL = 'f'             # a-zA-Z0-9

# List of characters, that are special to Regex. Listing them here and
# therefore escaping them will help making the Validator secure.
# NOTE: Please do not add '*', since it is used to determine inifinite
# long char symbol rows. (See examples at the of the file.)

DANGEROUSCHARS = '\\()+?.$'

class PatternChecker:
    """
    This class defines a basic user friendly checker and processor of
    string values according to pattern.
    It can verify whether a string value fits a certain pattern of
    digits and letters and possible special characters.
    """
    # a dictionary that converts an array of symbols to regex expressions
    symbol_regex_dict = {NUMBERSYMBOL  : '([0-9]{%i,%s})',
                         CHARSYMBOL    : '([a-zA-Z]{%i,%s})',
                         NUMCHARSYMBOL : '([0-9a-zA-Z]{%i,%s})'}
    
    def _escape(self, match_object):
        """Escape a single character.
        """ 
        return '\\' + match_object.group(0)
    
    def _escape_special_characters(self, s):
        """Escape the characters that have a special meaning in regex.
        """
        return re.sub('[' + DANGEROUSCHARS + ']', self._escape, s)

    def _unescape_special_characters(self, s):
        """Reverse the escaping, so that the final string is as close as
        possible to the original one.
        """
        return re.sub('\\\\', '', s)

    def _replace_symbol_by_regex(self, match_object):
        """Replace the character symbol with their respective regex.
        """
        length = len(match_object.group(0))

        # Yikes, what a hack! But I could not come up with something better.
        if match_object.group(0)[-1] == '*':
            min = length - 1
            max = ''
        else:
            min = length
            max = str(min)
            
        return self.symbol_regex_dict[match_object.group(0)[0]] %(min, max)

    def make_regex_from_pattern(self, pattern):
        """Replaces all symbol occurences and creates a complete regex
        string.
        """
        regex = self._escape_special_characters(pattern)
        for symbol in [NUMBERSYMBOL, CHARSYMBOL, NUMCHARSYMBOL]:
            regex = re.sub(symbol+'{1,}\*?', self._replace_symbol_by_regex, regex)
        return '^ *' + regex + ' *$'
    
    def construct_value_from_match(self, result, pattern):
        """After we validated the string, we put it back together; this is
        good, since we can easily clean up the data this way.
        """
        value = self._escape_special_characters(pattern)
        _symbols = '['+NUMBERSYMBOL + CHARSYMBOL + NUMCHARSYMBOL + ']'
        re_obj = re.compile(_symbols+'{1,}\*?')
        for res in result.groups():
            match = re_obj.search(value)
            value = value[:match.start()] + res + value[match.end():]
        return value

    def clean_value(self, value):
        """Clean up unnecessary white characters.
        """
        # same as string.strip, but since I am using re everywhere here,
        # why not use it now too?
        value = re.sub('^\s*', '', value)
        value = re.sub('\s*$', '', value)
        # make out of several white spaces, one whitespace...
        value = re.sub('  *', ' ', value)
        return value
    
    def validate_value(self, patterns, value):
        """Validate method that manges the entire validation process.
        
        The validator goes through each pattern and
        tries to get a match to the value (second parameter). At the end, the
        first pattern of the list is taken to construct the value again; this
        ensures data cleansing and a common data look.
        """
        value = self.clean_value(value)

        result = None
        for pattern in patterns:
            regex = self.make_regex_from_pattern(pattern)
            re_obj = re.compile(regex)
            result = re_obj.search(value)
            if result:
                break

        if not result:
            return None

        value = self.construct_value_from_match(result, patterns[0])
        return self._unescape_special_characters(value)

if __name__ == '__main__':

    val = PatternChecker()

    # American long ZIP
    print val.validate_value(['ddddd-dddd'], '34567-1298')
    print val.validate_value(['ddddd-dddd'], '  34567-1298  \t  ')

    # American phone number
    print val.validate_value(['(ddd) ddd-dddd', 'ddd-ddd-dddd',
                              'ddd ddd-dddd'],
                             '(345) 678-1298')
    print val.validate_value(['(ddd) ddd-dddd', 'ddd-ddd-dddd',
                              'ddd ddd-dddd'],
                             '345-678-1298')

    # American money
    print val.validate_value(['$ d*.dd'], '$ 1345345.00')

    # German money
    print val.validate_value(['d*.dd DM'], '267.98 DM')

    # German license plate 
    print val.validate_value(['eee ee-ddd'], 'OSL HR-683')

    # German phone number (international)
    print val.validate_value(['+49 (d*) d*'], '+49 (3574) 7253')
    print val.validate_value(['+49 (d*) d*'], '+49  (3574)  7253')











=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/PatternValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: PatternValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from StringValidator import StringValidator

class PatternValidator(StringValidator):

    __implements__ = StringValidator.__implements__

    # does the real work
    checker = PatternChecker.PatternChecker()
    
    propertyNames = StringValidator.propertyNames +\
                     ['pattern']

    pattern = ""

    messageNames = StringValidator.messageNames +\
                    ['patternNotMatched']

    patternNotMatched = "The entered value did not match the pattern."

    def validate(self, field, value):
        value = StringValidator.validate(self, field, value)
        
        if value == "" and not field.get_value('isRequired'):
            return value

        value = self.checker.validate_value([field.get_value('pattern')],
                                            value)
        if value is None:
            self.raise_error('patternNotMatched', field)
        return value


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/SelectionValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: SelectionValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from SelectionValidator import SelectionValidator


class SelectionValidator(StringBaseValidator):

    __implements__ = StringBaseValidator.__implements__

    messageNames = StringBaseValidator.messageNames +\
                   ['unknownSelection']

    unknownSelection = 'You selected an item that was not in the list.'
    
    def validate(self, field, value):
        value = StringBaseValidator.validate(self, field, value)

        if value == "" and not field.get_value('required'):
            return value

        # get the text and the value from the list of items
        for item in field.get_value('items'):
            try:
                item_text, item_value = item
            except ValueError:
                item_text = item
                item_value = item
            
            # check if the value is equal to the *string* version of
            # item_value; if that's the case, we can return the *original*
            # value in the list (not the submitted value). This way, integers
            # will remain integers.
            if str(item_value) == value:
                return item_value
            
        # if we didn't find the value, return error
        self.raise_error('unknownSelection', field)


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/StringBaseValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: StringBaseValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from Validator import Validator

  
class StringBaseValidator(Validator):
    """Simple string validator.
    """

    __implements__ = Validator.__implements__
    
    propertyNames = Validator.propertyNames + ['required']
    messageNames = Validator.messageNames + ['requiredNotFound']
    
    requiredNotFound = 'Input is required but no input given.'
    illegalValue = 'The value is not a string.'

        
    def validate(self, field, value):
        """ """
        if type(value) != type(''):
            self.raiseError('illegalValue', field)
        value = value.strip()
        if field.getValue('isRequired') and value == "":
            self.raiseError('requiredNotFound', field)

        return value


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/StringBaseValidator.pyc ===
-í
fQ<c       s9     d  Z    d k l Z  d e f d „  ƒ  YZ d S(   s   

Revision information: $Id: StringBaseValidator.pyc,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
(   s	   Validators   StringBaseValidatorc      s^    d  Z    e i Z  e i d g Z  e i d g Z  d Z  d Z " d „  Z RS(   s   Simple string validator.
    s   requireds   requiredNotFounds%   Input is required but no input given.s   The value is not a string.c    sŠ   " # $ t  | ƒ t  d ƒ j o % |  i d | ƒ n & | i ƒ  } ' | i d ƒ o
 | d j o ( |  i d | ƒ n * | Sd S(   s    s    s   illegalValues
   isRequireds   requiredNotFoundN(   s   types   values   selfs
   raiseErrors   fields   strips   getValue(   s   selfs   fields   value(    (    sK   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/StringBaseValidator.pys   validate" s    (   s   __doc__s	   Validators   __implements__s
   propertyNamess   messageNamess   requiredNotFounds   illegalValues   validate(    (    (    sK   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/StringBaseValidator.pys   StringBaseValidator s   			N(   s   __doc__s	   Validators   StringBaseValidator(   s	   Validators   StringBaseValidator(    (    sK   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/StringBaseValidator.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/StringValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: StringValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from StringBaseValidator import StringBaseValidator


class StringValidator(StringBaseValidator):
    """ """

    __implements__ = StringBaseValidator.__implements__
    

    propertyNames = StringBaseValidator.propertyNames + \
                    ['maxLength', 'truncate']
    maxLength = 0
    truncate = 0
    
    messageNames = StringBaseValidator.messageNames + \
                    ['tooLong']

    tooLong = 'Too much input was given.'


    def validate(self, field, value):
        value = StringBaseValidator.validate(self, field, value)

        maxLength = self.maxLength or 0
        
        if maxLength > 0 and len(value) > maxLength:
            if self.truncate:
                value = value[:maxLength]
            else:
                self.raiseError('tooLong', field)

        return value



=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/StringValidator.pyc ===
-í
fQ<c       s9     d  Z    d k l Z  d e f d „  ƒ  YZ d S(   s   

Revision information: $Id: StringValidator.pyc,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
(   s   StringBaseValidators   StringValidatorc      sj    d  Z    e i Z  e i d d g Z  d Z  d Z   e i d g Z # d Z & d „  Z RS(   s    s	   maxLengths   truncatei    s   tooLongs   Too much input was given.c    s‘   & ' t  i |  | | ƒ } ) |  i p d } + | d j o t | ƒ | j o5 , |  i o - | |  } n / |  i d | ƒ n 1 | Sd  S(   Ni    s   tooLong(	   s   StringBaseValidators   validates   selfs   fields   values	   maxLengths   lens   truncates
   raiseError(   s   selfs   fields   values	   maxLength(    (    sG   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/StringValidator.pys   validate& s   #
(	   s   __doc__s   StringBaseValidators   __implements__s
   propertyNamess	   maxLengths   truncates   messageNamess   tooLongs   validate(    (    (    sG   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/StringValidator.pys   StringValidator s   				N(   s   __doc__s   StringBaseValidators   StringValidator(   s   StringValidators   StringBaseValidator(    (    sG   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/StringValidator.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/TextValidator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: TextValidator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from LinesValidator import LinesValidator

class TextValidator(LinesValidator):
    """ """
    
    def validate(self, field, value):
        value = LinesValidator.validate(self, field, value)
        # we need to add this check again
        if value == [] and not field.get_value('isRequired'):
            return ""

        # join everything into string again with \n and return
        return "\n".join(value)



=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/Validator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: Validator.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""

from Zope.App.Formulator.Errors import ValidationError
from IValidator import IValidator

class Validator:
    """Validates input and possibly transforms it to output.
    """

    __implements__ = IValidator
    
    propertyNames = ['externalValidator']
    externalValidator = None
    
    messageNames = ['externalValidatorFailed']
    externalValidatorFailed = "The input failed the external validator."

    
    def raiseError(self, errorKey, field):
        raise ValidationError(errorKey, field)

    
    def validate(self, field, value):    
        pass


    def getMessage(self, name):
        """ """
        if name in self.messageNames:
            return getattr(self, name)


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/Validator.pyc ===
-í
]fQ<c       sF     d  Z    d k l Z  d k l Z  d f  d „  ƒ  YZ d S(   s   

Revision information: $Id: Validator.pyc,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
(   s   ValidationError(   s
   IValidators	   Validatorc      se    d  Z    e Z  d g Z  e Z  d g Z  d Z " d „  Z & d „  Z	 * d „  Z
 RS(   s:   Validates input and possibly transforms it to output.
    s   externalValidators   externalValidatorFaileds(   The input failed the external validator.c    s   " # t  | | ƒ ‚ d  S(   N(   s   ValidationErrors   errorKeys   field(   s   selfs   errorKeys   field(    (    sA   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/Validator.pys
   raiseError" s   c    s
   & ' d  S(   N(    (   s   selfs   fields   value(    (    sA   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/Validator.pys   validate& s   c    s1   * + , | |  i j o - t |  | ƒ Sn d S(   s    N(   s   names   selfs   messageNamess   getattr(   s   selfs   name(    (    sA   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/Validator.pys
   getMessage* s   (   s   __doc__s
   IValidators   __implements__s
   propertyNamess   Nones   externalValidators   messageNamess   externalValidatorFaileds
   raiseErrors   validates
   getMessage(    (    (    sA   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/Validator.pys	   Validator s   				N(   s   __doc__s   Zope.App.Formulator.Errorss   ValidationErrors
   IValidators	   Validator(   s	   Validators   ValidationErrors
   IValidator(    (    sA   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/Validator.pys   ? s   

=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/__init__.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: __init__.py,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
"""


=== Added File Zope3/lib/python/Zope/App/Formulator/Validators/__init__.pyc ===
-í
rfQ<c       s     d  Z   d S(   s   

Revision information: $Id: __init__.pyc,v 1.1.2.1 2002/01/25 14:11:08 srichter Exp $
N(   s   __doc__(    (    (    s@   /opt/Zope3/lib/python/Zope/App/Formulator/Validators/__init__.pys   ? s