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

Source Code for Module ZenModel.ZenMenu

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13   
14   
15  from Globals import InitializeClass 
16  from Products.ZenModel.ZenModelRM import ZenModelRM 
17  from ZenMenuItem import ZenMenuItem 
18  from Products.ZenRelations.RelSchema import * 
19  from AccessControl import ClassSecurityInfo, Permissions 
20  import logging 
21  log = logging.getLogger("zen.Menu") 
22   
23  from ZenPackable import ZenPackable 
24   
25   
26 -class ZenMenu(ZenModelRM, ZenPackable):
27 """ A Menu object that holds Menu Items. 28 """ 29 30 meta_type = 'ZenMenu' 31 description = "" 32 33 _properties = ( 34 {'id':'description', 'type':'text', 'mode':'w'}, 35 ) 36 37 _relations = ZenPackable._relations + ( 38 ("zenMenuItems", ToManyCont( 39 ToOne, 'Products.ZenModel.ZenMenuItem', 'zenMenus')), 40 ("menuable", ToOne( 41 ToManyCont, 'Products.ZenModel.ZenMenuable', 'zenMenus')), 42 ) 43 44 security = ClassSecurityInfo() 45 46 security.declareProtected('Change Device', 'manage_addZenMenuItem')
47 - def manage_addZenMenuItem(self, id=None, description='', action='', 48 permissions=(Permissions.view,), isdialog=False, isglobal=True, 49 banned_classes=(), allowed_classes=(), ordering=0.0, REQUEST=None):
50 """ Add a menu item to a menu """ 51 mi = None 52 if id: 53 mi = ZenMenuItem(id) 54 try: self.zenMenuItems._delObject(id) 55 except AttributeError: pass 56 self.zenMenuItems._setObject(id, mi) 57 mi = self.zenMenuItems._getOb(mi.id) 58 mi.description = description 59 mi.action = action 60 mi.permissions = permissions 61 mi.isdialog = isdialog 62 mi.isglobal = isglobal 63 mi.banned_classes = list(banned_classes) 64 mi.allowed_classes = list(allowed_classes) 65 mi.ordering = ordering 66 return mi
67 68 security.declareProtected('Change Device', 'manage_deleteZenMenuItem')
69 - def manage_deleteZenMenuItem(self, delids=(), REQUEST=None):
70 """ Delete Menu Items """ 71 if isinstance(delids, (str,unicode)): delids = [delids] 72 for id in delids: 73 self.zenMenuItems._delObject(id)
74 75 76 InitializeClass(ZenMenu) 77