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

Source Code for Module ZenModel.ZenMenuItem

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