src/pyams_content/shared/common/interfaces/types.py
changeset 276 78422a1c4228
child 622 76b7c0b5bfa6
equal deleted inserted replaced
275:0c63253d75bd 276:78422a1c4228
       
     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 pyams_content.shared.common.interfaces import ISharedTool
       
    20 from zope.container.interfaces import IContainer
       
    21 from zope.location.interfaces import ILocation
       
    22 
       
    23 # import packages
       
    24 from pyams_i18n.schema import I18nTextLineField, I18nThumbnailImageField
       
    25 from zope.container.constraints import contains
       
    26 from zope.interface import Attribute
       
    27 from zope.schema import TextLine, List, Choice
       
    28 
       
    29 from pyams_content import _
       
    30 
       
    31 
       
    32 class IBaseDataType(ILocation):
       
    33     """Data interface for data-types and sub-types"""
       
    34 
       
    35     name = TextLine(title=_("Name"),
       
    36                     description=_("Name of this data type; must be unique between all data types"),
       
    37                     required=True)
       
    38 
       
    39     label = I18nTextLineField(title=_("Label"),
       
    40                               required=True)
       
    41 
       
    42     navigation_label = I18nTextLineField(title=_("Navigation label"),
       
    43                                          description=_("Label used for navigation entries"),
       
    44                                          required=False)
       
    45 
       
    46     tabfolder_label = I18nTextLineField(title=_("Tab-folder label"),
       
    47                                         description=_("Label used to include into tab folder"),
       
    48                                         required=False)
       
    49 
       
    50     seealso_label = I18nTextLineField(title=_("'See also' label"),
       
    51                                       description=_("This label can be used when contents of this type will be "
       
    52                                                     "displayed in a 'See also' entries block"),
       
    53                                       required=False)
       
    54 
       
    55     single_label = I18nTextLineField(title=_("'Single value' label"),
       
    56                                      description=_("Label given to this type when a single value is displayed"),
       
    57                                      required=False)
       
    58 
       
    59     seeall_label = I18nTextLineField(title=_("'Link to list' label"),
       
    60                                      description=_("Label used to display a link to a list of items of this type"),
       
    61                                      required=False)
       
    62 
       
    63     next_label = I18nTextLineField(title=_("Next content label"),
       
    64                                    description=_("Label used to announce next date for this type"),
       
    65                                    required=False)
       
    66 
       
    67     pictogram = I18nThumbnailImageField(title=_("Pictogram"),
       
    68                                         description=_("Image associated to this data type"),
       
    69                                         required=False)
       
    70 
       
    71 
       
    72 class ISubType(IBaseDataType):
       
    73     """Data sub-type interface"""
       
    74 
       
    75 
       
    76 class IDataType(IBaseDataType, IContainer):
       
    77     """Data type interface"""
       
    78 
       
    79     contains(ISubType)
       
    80 
       
    81     field_names = List(title=_("Field names"),
       
    82                        description=_("List of fields associated with this data type"),
       
    83                        value_type=Choice(vocabulary='PyAMS types interface fields'))
       
    84 
       
    85 
       
    86 #
       
    87 # Types data manager interfaces
       
    88 #
       
    89 
       
    90 DATA_MANAGER_ANNOTATION_KEY = 'pyams_content.types.manager'
       
    91 
       
    92 
       
    93 class ITypedDataManager(IContainer):
       
    94     """Typed shared data manager interface"""
       
    95 
       
    96     contains(IDataType)
       
    97 
       
    98 
       
    99 class ITypedSharedTool(ISharedTool):
       
   100     """Shared tool containing typed data"""
       
   101 
       
   102     shared_content_types_fields = Attribute("Content fields interface")