equal
deleted
inserted
replaced
63 """ |
63 """ |
64 __docformat__ = "restructuredtext en" |
64 __docformat__ = "restructuredtext en" |
65 |
65 |
66 from warnings import warn |
66 from warnings import warn |
67 from datetime import datetime, timedelta |
67 from datetime import datetime, timedelta |
|
68 |
|
69 from six import string_types |
68 |
70 |
69 from logilab.mtconverter import xml_escape |
71 from logilab.mtconverter import xml_escape |
70 from logilab.common import nullobject |
72 from logilab.common import nullobject |
71 from logilab.common.date import ustrftime |
73 from logilab.common.date import ustrftime |
72 from logilab.common.configuration import format_time |
74 from logilab.common.configuration import format_time |
840 super(BigIntField, self).init_widget(widget) |
842 super(BigIntField, self).init_widget(widget) |
841 if isinstance(self.widget, fw.TextInput): |
843 if isinstance(self.widget, fw.TextInput): |
842 self.widget.attrs.setdefault('size', self.default_text_input_size) |
844 self.widget.attrs.setdefault('size', self.default_text_input_size) |
843 |
845 |
844 def _ensure_correctly_typed(self, form, value): |
846 def _ensure_correctly_typed(self, form, value): |
845 if isinstance(value, basestring): |
847 if isinstance(value, string_types): |
846 value = value.strip() |
848 value = value.strip() |
847 if not value: |
849 if not value: |
848 return None |
850 return None |
849 try: |
851 try: |
850 return int(value) |
852 return int(value) |
922 |
924 |
923 def render_example(self, req): |
925 def render_example(self, req): |
924 return self.format_single_value(req, 1.234) |
926 return self.format_single_value(req, 1.234) |
925 |
927 |
926 def _ensure_correctly_typed(self, form, value): |
928 def _ensure_correctly_typed(self, form, value): |
927 if isinstance(value, basestring): |
929 if isinstance(value, string_types): |
928 value = value.strip() |
930 value = value.strip() |
929 if not value: |
931 if not value: |
930 return None |
932 return None |
931 try: |
933 try: |
932 return float(value) |
934 return float(value) |
954 field |
956 field |
955 """ |
957 """ |
956 return u'20s, 10min, 24h, 4d' |
958 return u'20s, 10min, 24h, 4d' |
957 |
959 |
958 def _ensure_correctly_typed(self, form, value): |
960 def _ensure_correctly_typed(self, form, value): |
959 if isinstance(value, basestring): |
961 if isinstance(value, string_types): |
960 value = value.strip() |
962 value = value.strip() |
961 if not value: |
963 if not value: |
962 return None |
964 return None |
963 try: |
965 try: |
964 value = apply_units(value, TIME_UNITS) |
966 value = apply_units(value, TIME_UNITS) |
984 |
986 |
985 def render_example(self, req): |
987 def render_example(self, req): |
986 return self.format_single_value(req, datetime.now()) |
988 return self.format_single_value(req, datetime.now()) |
987 |
989 |
988 def _ensure_correctly_typed(self, form, value): |
990 def _ensure_correctly_typed(self, form, value): |
989 if isinstance(value, basestring): |
991 if isinstance(value, string_types): |
990 value = value.strip() |
992 value = value.strip() |
991 if not value: |
993 if not value: |
992 return None |
994 return None |
993 try: |
995 try: |
994 value = form._cw.parse_datetime(value, self.etype) |
996 value = form._cw.parse_datetime(value, self.etype) |