src/pyams_utils/interfaces/timezone.py
changeset 1 3f89629b9e54
child 419 05ff71a02b2d
equal deleted inserted replaced
0:16d47bd81d84 1:3f89629b9e54
       
     1 #
       
     2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 from zope.schema.interfaces import IChoice
       
    20 
       
    21 # import packages
       
    22 from zope.interface import implementer, Interface
       
    23 from zope.schema import Choice
       
    24 
       
    25 from pyams_utils import _
       
    26 
       
    27 
       
    28 class ITimezone(IChoice):
       
    29     """Marker interface for timezone field"""
       
    30 
       
    31 
       
    32 @implementer(ITimezone)
       
    33 class Timezone(Choice):
       
    34     """Timezone choice field"""
       
    35 
       
    36     def __init__(self, **kw):
       
    37         if 'vocabulary' in kw:
       
    38             kw.pop('vocabulary')
       
    39         if 'default' not in kw:
       
    40             kw['default'] = u'GMT'
       
    41         super(Timezone, self).__init__(vocabulary='PyAMS timezones', **kw)
       
    42 
       
    43 
       
    44 class IServerTimezone(Interface):
       
    45     """Server timezone interface"""
       
    46 
       
    47     timezone = Timezone(title=_("Server timezone"),
       
    48                         description=_("Default server timezone"),
       
    49                         required=True)