src/pyams_utils/interfaces/timezone.py
changeset 1 3f89629b9e54
child 419 05ff71a02b2d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_utils/interfaces/timezone.py	Thu Feb 19 00:46:48 2015 +0100
@@ -0,0 +1,49 @@
+#
+# 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 interfaces
+from zope.schema.interfaces import IChoice
+
+# import packages
+from zope.interface import implementer, Interface
+from zope.schema import Choice
+
+from pyams_utils import _
+
+
+class ITimezone(IChoice):
+    """Marker interface for timezone field"""
+
+
+@implementer(ITimezone)
+class Timezone(Choice):
+    """Timezone choice field"""
+
+    def __init__(self, **kw):
+        if 'vocabulary' in kw:
+            kw.pop('vocabulary')
+        if 'default' not in kw:
+            kw['default'] = u'GMT'
+        super(Timezone, self).__init__(vocabulary='PyAMS timezones', **kw)
+
+
+class IServerTimezone(Interface):
+    """Server timezone interface"""
+
+    timezone = Timezone(title=_("Server timezone"),
+                        description=_("Default server timezone"),
+                        required=True)