src/pyams_utils/timezone/vocabulary.py
changeset 1 3f89629b9e54
child 71 01d01045a2b7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_utils/timezone/vocabulary.py	Thu Feb 19 00:46:48 2015 +0100
@@ -0,0 +1,35 @@
+#
+# 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 pytz
+
+# import interfaces
+from zope.schema.interfaces import IVocabularyFactory
+
+# import packages
+from zope.interface import provider
+from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary, getVocabularyRegistry
+
+
+@provider(IVocabularyFactory)
+class TimezonesVocabulary(SimpleVocabulary):
+    """Timezones vocabulary"""
+
+    def __init__(self, *args, **kw):
+        terms = [SimpleTerm(t, t, t) for t in pytz.all_timezones]
+        super(TimezonesVocabulary, self).__init__(terms)
+
+getVocabularyRegistry().register('PyAMS timezones', TimezonesVocabulary)