src/ztfy/utils/schema.py
branchZTK-1.1
changeset 190 5152d59c147c
parent 165 9615e7d1a4ee
child 197 67242b459a6d
equal deleted inserted replaced
189:c9ce3999f76b 190:5152d59c147c
    18 import decimal
    18 import decimal
    19 import string
    19 import string
    20 
    20 
    21 # import Zope3 interfaces
    21 # import Zope3 interfaces
    22 from z3c.form.interfaces import IWidget
    22 from z3c.form.interfaces import IWidget
    23 from zope.schema.interfaces import ITextLine, IDecimal, IList
    23 from zope.schema.interfaces import ITextLine, IDecimal, IList, ITuple
    24 
    24 
    25 # import local interfaces
    25 # import local interfaces
    26 
    26 
    27 # import Zope3 packages
    27 # import Zope3 packages
    28 from z3c.form.converter import BaseDataConverter, FormatterValidationError
    28 from z3c.form.converter import BaseDataConverter, FormatterValidationError
    29 from zope.component import adapts
    29 from zope.component import adapts
    30 from zope.interface import implements
    30 from zope.interface import implements
    31 from zope.schema import TextLine, Decimal, List
    31 from zope.schema import TextLine, Decimal, List, Tuple, Date
    32 from zope.schema._bootstrapfields import InvalidValue
    32 from zope.schema._bootstrapfields import InvalidValue
    33 
    33 
    34 # import local packages
    34 # import local packages
    35 
    35 
    36 from ztfy.utils import _
    36 from ztfy.utils import _
   109         except decimal.InvalidOperation:
   109         except decimal.InvalidOperation:
   110             raise FormatterValidationError(self.errorMessage, value)
   110             raise FormatterValidationError(self.errorMessage, value)
   111 
   111 
   112 
   112 
   113 #
   113 #
       
   114 # Dates range field
       
   115 #
       
   116 
       
   117 class IDatesRangeField(ITuple):
       
   118     """Marker interface for dates range fields"""
       
   119 
       
   120 
       
   121 class DatesRangeField(Tuple):
       
   122     """Dates range field"""
       
   123 
       
   124     implements(IDatesRangeField)
       
   125 
       
   126     def __init__(self, value_type=None, unique=False, **kw):
       
   127         super(DatesRangeField, self).__init__(value_type=None, unique=False,
       
   128                                               min_length=2, max_length=2, **kw)
       
   129 
       
   130 
       
   131 #
   114 # TextLine list field
   132 # TextLine list field
   115 #
   133 #
   116 
   134 
   117 class ITextLineListField(IList):
   135 class ITextLineListField(IList):
   118     """Marker interface for textline list field"""
   136     """Marker interface for textline list field"""