src/pyams_content/features/menu/__init__.py
changeset 635 ac6c59149f0d
child 810 7b5d910b2205
equal deleted inserted replaced
634:4e43b556a2a9 635:ac6c59149f0d
       
     1 #
       
     2 # Copyright (c) 2008-2018 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.features.menu.interfaces import IMenu, IMenusContainer, IMenuLink
       
    20 
       
    21 # import packages
       
    22 from pyams_content.component.association.container import AssociationContainer
       
    23 from zope.interface import implementer
       
    24 from zope.schema.fieldproperty import FieldProperty
       
    25 
       
    26 
       
    27 #
       
    28 # Menus classes
       
    29 #
       
    30 
       
    31 @implementer(IMenu)
       
    32 class Menu(AssociationContainer):
       
    33     """Associations menu"""
       
    34 
       
    35     visible = FieldProperty(IMenu['visible'])
       
    36     title = FieldProperty(IMenu['title'])
       
    37 
       
    38 
       
    39 @implementer(IMenusContainer)
       
    40 class MenusContainer(AssociationContainer):
       
    41     """Associations menus container"""
       
    42 
       
    43     def get_visible_items(self):
       
    44         return filter(lambda x: IMenu(x).visible, self.values())