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

# Source Code for Module Products.ZenModel.ZenMenuItem

     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 Acquisition import aq_parent
    12  from Globals import InitializeClass
    13  from AccessControl import ClassSecurityInfo, Permissions
    14  from Products.ZenModel.ZenModelRM import ZenModelRM
    15  from Products.ZenModel.ZenPackable import ZenPackable
    16  from Products.ZenRelations.RelSchema import *
    17
    18  import logging
    19  log = logging.getLogger("zen.Menu")
    20
    21 -class ZenMenuItem(ZenModelRM, ZenPackable):
    22
    23      meta_type = 'ZenMenuItem'
    24      security = ClassSecurityInfo()
    25      description = ""
    26      action = ""
    27      permissions = (Permissions.view,)
    28      isglobal = True
    29      isdialog = False
    30      banned_classes = ()
    31      allowed_classes = ()
    32      banned_ids = ()
    33      ordering = 0.0
    34
    35      _properties = (
    36          {'id':'description', 'type':'text', 'mode':'w'},
    37          {'id':'action', 'type':'text', 'mode':'w'},
    38          {'id':'isglobal', 'type':'boolean','mode':'w'},
    39          {'id':'permissions', 'type':'lines', 'mode':'w'},
    40          {'id':'banned_classes','type':'lines','mode':'w'},
    41          {'id':'allowed_classes','type':'lines','mode':'w'},
    42          {'id':'banned_ids','type':'lines','mode':'w'},
    43          {'id':'isdialog', 'type':'boolean','mode':'w'},
    44          {'id':'ordering', 'type':'float','mode':'w'},
    45          )
    46
    47      _relations =  (
    48          ("zenMenus", ToOne(ToManyCont, 'Products.ZenModel.ZenMenu', 'zenMenuItems')),
    49          ) + ZenPackable._relations
    50
    51      security = ClassSecurityInfo()
    52
    53 -    def getMenuItemOwner(self):
    54          parent = self.primaryAq()
    55          for unused in range(4):
    56              parent = aq_parent(parent)
    57          return parent
    58
    59 -    def __cmp__(self, other):
    60          if isinstance(other, ZenMenuItem):
    61              if other and other.ordering:
    62                  return cmp(other.ordering, self.ordering)
    63              else:
    64                  return cmp(0.0, self.ordering)
    65          return cmp(id(self), id(other))
    66
    67  InitializeClass(ZenMenuItem)
    68