src/pyams_skin/interfaces/__init__.py
changeset 156 b8b688fc964e
parent 155 cd3ab32436f0
child 319 7ad85ca36f04
equal deleted inserted replaced
155:cd3ab32436f0 156:b8b688fc964e
    18 from pyams_skin.layer import IPyAMSLayer
    18 from pyams_skin.layer import IPyAMSLayer
    19 from zope.component.interfaces import IObjectEvent, ObjectEvent
    19 from zope.component.interfaces import IObjectEvent, ObjectEvent
    20 
    20 
    21 # import packages
    21 # import packages
    22 from pyams_template.template import layout_config
    22 from pyams_template.template import layout_config
    23 from zope.interface import implementer, Interface, Attribute
    23 from zope.interface import implementer, invariant, Interface, Attribute, Invalid
    24 from zope.configuration.fields import GlobalInterface
    24 from zope.configuration.fields import GlobalInterface
    25 from zope.schema import Text, TextLine, Choice, Int, Bool
    25 from zope.schema import Text, TextLine, Choice, Int, Bool
    26 
    26 
    27 from pyams_skin import _
    27 from pyams_skin import _
    28 
    28 
    60                         required=True,
    60                         required=True,
    61                         default=False)
    61                         default=False)
    62 
    62 
    63     skin_parent = Attribute("Skin parent (local or inherited)")
    63     skin_parent = Attribute("Skin parent (local or inherited)")
    64 
    64 
    65     skin = Choice(title=_("Presentation skin"),
    65     skin = Choice(title=_("Custom graphic theme"),
    66                   description=_("This skin will be used to handle presentation templates"),
    66                   description=_("This theme will be used to handle graphic design (colors and images)"),
    67                   vocabulary='PyAMS user skins')
    67                   vocabulary='PyAMS user skins',
       
    68                   required=False)
       
    69 
       
    70     @invariant
       
    71     def check_skin(self):
       
    72         if not (self.skin or self.inherit_skin):
       
    73             raise Invalid(_("You must select a custom skin or inherit from parent!"))
    68 
    74 
    69     def get_skin(self, request=None):
    75     def get_skin(self, request=None):
    70         """Get skin matching this content"""
    76         """Get skin matching this content"""
    71 
    77 
    72 
    78