| Trees | Indices | Help |
|
|---|
|
|
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
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=(), banned_ids=(), ordering=0.0,
50 REQUEST=None):
51 """ Add a menu item to a menu """
52 mi = None
53 if id:
54 mi = ZenMenuItem(id)
55 self.zenMenuItems._setObject(id, mi)
56 mi = self.zenMenuItems._getOb(mi.id)
57 mi.description = description
58 mi.action = action
59 mi.permissions = permissions
60 mi.isdialog = isdialog
61 mi.isglobal = isglobal
62 mi.banned_classes = list(banned_classes)
63 mi.allowed_classes = list(allowed_classes)
64 mi.banned_ids = list(banned_ids)
65 mi.ordering = ordering
66 return mi
67
68 security.declareProtected('Change Device', 'manage_deleteZenMenuItem')
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
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Thu May 7 11:46:48 2009 | http://epydoc.sourceforge.net |