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 |
23 from zope.schema.interfaces import ITextLine, IDecimal, IList |
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 |
31 from zope.schema import TextLine, Decimal, List |
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 _ |
106 return None |
106 return None |
107 try: |
107 try: |
108 return decimal.Decimal(value) |
108 return decimal.Decimal(value) |
109 except decimal.InvalidOperation: |
109 except decimal.InvalidOperation: |
110 raise FormatterValidationError(self.errorMessage, value) |
110 raise FormatterValidationError(self.errorMessage, value) |
|
111 |
|
112 |
|
113 # |
|
114 # TextLine list field |
|
115 # |
|
116 |
|
117 class ITextLineListField(IList): |
|
118 """Marker interface for textline list field""" |
|
119 |
|
120 |
|
121 class TextLineListField(List): |
|
122 """TextLine list field""" |
|
123 |
|
124 implements(ITextLineListField) |
|
125 |
|
126 def __init__(self, value_type=None, unique=False, **kw): |
|
127 super(TextLineListField, self).__init__(value_type=TextLine(), unique=True, **kw) |