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

Source Code for Module ZenModel.GraphGroup

  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  __doc__="""GraphGroup 
 15   
 16  GraphGroup contains the settings, graphDefinitions and collections 
 17  that form part of an UberReport. 
 18  """ 
 19   
 20   
 21  from AccessControl import Permissions 
 22  from Globals import InitializeClass 
 23  from AccessControl import ClassSecurityInfo 
 24  from Products.ZenRelations.RelSchema import * 
 25  from ZenModelRM import ZenModelRM 
 26   
 27   
28 -def manage_addGraphGroup(context, id, REQUEST = None):
29 ''' This is here so than zope will let us copy/paste/rename 30 ''' 31 gg = GraphGroup(id) 32 context._setObject(gg.id, gg) 33 if REQUEST: 34 return context.callZenScreen(REQUEST)
35 36
37 -class GraphGroup(ZenModelRM):
38 ''' 39 ''' 40 41 meta_type = 'GraphGroup' 42 43 sequence = 0 44 collectionId = '' 45 graphDefId = '' 46 combineDevices = False 47 48 _properties = ( 49 {'id':'sequence', 'type':'long', 'mode':'w'}, 50 {'id':'collectionId', 'type':'string', 'mode':'w'}, 51 {'id':'graphDefId', 'type':'string', 'mode':'w'}, 52 {'id':'combineDevices', 'type':'boolean', 'mode':'w'}, 53 ) 54 55 _relations = ( 56 ('report', 57 ToOne(ToMany, 'Products.ZenModel.MultiGraphReport', 'graphGroups')), 58 ) 59 60 factory_type_information = ( 61 { 62 'immediate_view' : 'editGraphGroup', 63 'actions' : 64 ( 65 { 'id' : 'edit' 66 , 'name' : 'Graph Group' 67 , 'action' : 'editGraphGroup' 68 , 'permissions' : ( Permissions.view, ) 69 }, 70 ) 71 }, 72 ) 73 74 security = ClassSecurityInfo() 75
76 - def __init__(self, newId, collectionId='', graphDefId='', sequence=0, 77 title=None, buildRelations=True):
82 83
84 - def getCollection(self):
85 ''' Return the referenced collection or None if it doesn't exist 86 ''' 87 return getattr(self.report.collections, self.collectionId, None)
88 89
90 - def getGraphDef(self):
91 ''' Return the referenced graphDef or None if it doesn't exist 92 ''' 93 return getattr(self.report().graphDefs, self.graphDefId, None)
94 95
96 - def getCollectionUrl(self):
97 ''' 98 ''' 99 collection = self.getCollection() 100 url = None 101 if collection: 102 url = collection.getPrimaryUrlPath() 103 return url
104 105
106 - def getGraphDefUrl(self):
107 ''' 108 ''' 109 graphDef = self.getGraphDef() 110 url = None 111 if graphDef: 112 url = graphDef.getPrimaryUrlPath() 113 return url
114 115 116 # def zmanage_editProperties(self, REQUEST): 117 # ''' Save then redirect back to the report 118 # ''' 119 # self.manage_changeProperties(**REQUEST.form) 120 # index_object = getattr(self, 'index_object', lambda self: None) 121 # index_object() 122 # REQUEST['RESPONSE'].redirect(self.report().getPrimaryUrlPath()) 123 124 125 InitializeClass(GraphGroup) 126