Package Products :: Package ZenModel :: Module ZenMenu |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenModel.ZenMenu

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  from Globals import InitializeClass
    12  from Products.ZenModel.ZenModelRM import ZenModelRM
    13  from ZenMenuItem import ZenMenuItem
    14  from Products.ZenRelations.RelSchema import *
    15  from AccessControl import ClassSecurityInfo, Permissions
    16  import logging
    17  log = logging.getLogger("zen.Menu")
    18
    19  from ZenPackable import ZenPackable
    20
    21
    22 -class ZenMenu(ZenModelRM, ZenPackable):
    23      """ A Menu object that holds Menu Items.
    24      """
    25
    26      meta_type = 'ZenMenu'
    27      description = ""
    28
    29      _properties = (
    30          {'id':'description', 'type':'text', 'mode':'w'},
    31          )
    32
    33      _relations =  ZenPackable._relations + (
    34          ("zenMenuItems", ToManyCont(
    35              ToOne, 'Products.ZenModel.ZenMenuItem', 'zenMenus')),
    36          ("menuable", ToOne(
    37              ToManyCont, 'Products.ZenModel.ZenMenuable', 'zenMenus')),
    38          )
    39
    40      security = ClassSecurityInfo()
    41
    42      security.declareProtected('Change Device', 'manage_addZenMenuItem')
    43 -    def manage_addZenMenuItem(self, id=None, description='', action='',
    44              permissions=(Permissions.view,), isdialog=False, isglobal=True,
    45              banned_classes=(), allowed_classes=(), banned_ids=(), ordering=0.0,
    46                                REQUEST=None):
    47          """ Add a menu item to a menu """
    48          mi = None
    49          if id:
    50              mi = ZenMenuItem(id)
    51              self.zenMenuItems._setObject(id, mi)
    52              mi = self.zenMenuItems._getOb(mi.id)
    53              mi.description = description
    54              mi.action = action
    55              mi.permissions = permissions
    56              mi.isdialog = isdialog
    57              mi.isglobal = isglobal
    58              mi.banned_classes = list(banned_classes)
    59              mi.allowed_classes = list(allowed_classes)
    60              mi.banned_ids = list(banned_ids)
    61              mi.ordering = ordering
    62          return mi
    63
    64      security.declareProtected('Change Device', 'manage_deleteZenMenuItem')
    65 -    def manage_deleteZenMenuItem(self, delids=(), REQUEST=None):
    66          """ Delete Menu Items """
    67          if isinstance(delids, (str,unicode)): delids = [delids]
    68          for id in delids:
    69              self.zenMenuItems._delObject(id)
    70
    71
    72  InitializeClass(ZenMenu)
    73