Renamed 'browser' package to 'views'
authorThierry Florac <tflorac@ulthar.net>
Sat, 21 Feb 2015 13:51:51 +0100
changeset 2 a4db31e40fe1
parent 1 3f89629b9e54
child 3 2919bac002e3
Renamed 'browser' package to 'views'
src/pyams_utils/views/__init__.py
src/pyams_utils/views/decimal.py
src/pyams_utils/widget/__init__.py
src/pyams_utils/widget/decimal.py
--- a/src/pyams_utils/views/__init__.py	Thu Feb 19 00:46:48 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-#
--- a/src/pyams_utils/views/decimal.py	Thu Feb 19 00:46:48 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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.
-#
-
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
-import decimal
-
-# import interfaces
-from z3c.form.interfaces import IWidget, IDataConverter
-
-# import packages
-from pyams_utils.adapter import adapter_config
-from pyams_utils.schema import IDottedDecimalField
-from z3c.form.converter import BaseDataConverter, FormatterValidationError
-
-from pyams_utils import _
-
-
-@adapter_config(context=(IDottedDecimalField, IWidget), provides=IDataConverter)
-class DottedDecimalDataConverter(BaseDataConverter):
-    """Dotted decimal field data converter"""
-
-    errorMessage = _('The entered value is not a valid decimal literal.')
-
-    def __init__(self, field, widget):
-        super(DottedDecimalDataConverter, self).__init__(field, widget)
-
-    def toWidgetValue(self, value):
-        if not value:
-            return self.field.missing_value
-        return value
-
-    def toFieldValue(self, value):
-        if value is self.field.missing_value:
-            return ''
-        if not value:
-            return None
-        try:
-            return decimal.Decimal(value)
-        except decimal.InvalidOperation:
-            raise FormatterValidationError(self.errorMessage, value)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_utils/widget/__init__.py	Sat Feb 21 13:51:51 2015 +0100
@@ -0,0 +1,1 @@
+#
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_utils/widget/decimal.py	Sat Feb 21 13:51:51 2015 +0100
@@ -0,0 +1,52 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+import decimal
+
+# import interfaces
+from z3c.form.interfaces import IWidget, IDataConverter
+
+# import packages
+from pyams_utils.adapter import adapter_config
+from pyams_utils.schema import IDottedDecimalField
+from z3c.form.converter import BaseDataConverter, FormatterValidationError
+
+from pyams_utils import _
+
+
+@adapter_config(context=(IDottedDecimalField, IWidget), provides=IDataConverter)
+class DottedDecimalDataConverter(BaseDataConverter):
+    """Dotted decimal field data converter"""
+
+    errorMessage = _('The entered value is not a valid decimal literal.')
+
+    def __init__(self, field, widget):
+        super(DottedDecimalDataConverter, self).__init__(field, widget)
+
+    def toWidgetValue(self, value):
+        if not value:
+            return self.field.missing_value
+        return value
+
+    def toFieldValue(self, value):
+        if value is self.field.missing_value:
+            return ''
+        if not value:
+            return None
+        try:
+            return decimal.Decimal(value)
+        except decimal.InvalidOperation:
+            raise FormatterValidationError(self.errorMessage, value)