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 __doc__="""ReportClass 15 16 ReportClass groups different types of reports together 17 18 $Id: ReportClass.py,v 1.3 2004/04/22 15:33:44 edahl Exp $""" 19 20 __version__ = "$Revision: 1.3 $"[11:-2] 21 22 import types 23 24 from AccessControl import ClassSecurityInfo 25 from Globals import InitializeClass 26 from OFS.Folder import Folder 27 from Globals import DTMLFile 28 29 from Products.PageTemplates.PageTemplateFile import PageTemplateFile 30 31 from Organizer import Organizer 32 from Report import Report 33 from ZenPackable import ZenPackable 34 from ZenossSecurity import ZEN_MANAGE_DMD, ZEN_COMMON 35 from Products.ZenRelations.RelSchema import * 3638 """make a device class""" 39 dc = ReportClass(id, title) 40 context._setObject(id, dc) 41 42 if REQUEST is not None: 43 REQUEST['message'] = "Report organizer created" 44 REQUEST['RESPONSE'].redirect(context.absolute_url() + '/manage_main')45 46 addReportClass = DTMLFile('dtml/addReportClass',globals()) 4749 dmdRootName = "Reports" 50 portal_type = meta_type = "ReportClass" 51 52 #sub_meta_types = ("ReportClass", "Report", 'DeviceReport', 'GraphReport', 53 # 'MultiGraphReportClass') 54 55 _relations = Organizer._relations + ZenPackable._relations 56 57 # Screen action bindings (and tab definitions) 58 factory_type_information = ( 59 { 60 'immediate_view' : 'viewReportClass', 61 'actions' : 62 ( 63 { 'id' : 'view' 64 , 'name' : 'Status' 65 , 'action' : 'viewReportClass' 66 , 'permissions' : ( "View",) 67 , 'visible' : 1 68 }, 69 ) 70 }, 71 ) 72 73 security = ClassSecurityInfo() 74 75 security.declareProtected(ZEN_COMMON, "children")168 169 170 171 InitializeClass(ReportClass) 17277 ''' Return all objects that are instances of ReportClass 78 ''' 79 kids = [o for o in self.objectValues() if isinstance(o, ReportClass)] 80 if checkPerm: 81 kids = [kid for kid in kids if self.checkRemotePerm("View", kid)] 82 if sort: kids.sort(lambda x,y: cmp(x.primarySortKey(), 83 y.primarySortKey())) 84 return kids85 86 90 91 92 security.declareProtected(ZEN_COMMON, "countChildren")94 """Return a count of all our contained children.""" 95 count = len(self.childIds()) 96 for child in self.children(): 97 count += child.countChildren() 98 return count99 100 105 106108 """make a device class""" 109 rClass = self.getReportClass() 110 dc = rClass(id, title) 111 self._setObject(id, dc) 112 if REQUEST: 113 REQUEST['message'] = "Report organizer created" 114 return self.callZenScreen(REQUEST)115 116118 """Return list of report instances. 119 """ 120 return [ r for r in self.objectValues( 121 spec=('Report','DeviceReport','GraphReport','MultiGraphReport')) ]122 123125 """Return a count of all our contained children.""" 126 count = len(self.reports()) 127 for child in self.children(): 128 count += child.countReports() 129 return count130 131 132 security.declareProtected('Manage DMD', 'manage_addGraphReport')134 """Add an graph report to this object. 135 """ 136 if id: 137 from Products.ZenModel.GraphReport import GraphReport 138 gr = GraphReport(id) 139 self._setObject(id, gr) 140 if REQUEST: 141 REQUEST['message'] = "Graph report created" 142 return self.callZenScreen(REQUEST)143 144146 """Move a report from here organizer to moveTarget. 147 """ 148 if not moveTarget or not ids: return self() 149 if type(ids) in types.StringTypes: ids = (ids,) 150 target = self.getOrganizer(moveTarget) 151 for rptname in ids: 152 rpt = self._getOb(rptname) 153 rpt._operation = 1 # moving object state 154 self._delObject(rptname) 155 target._setObject(rptname, rpt) 156 if REQUEST: 157 REQUEST['message'] = "Device reports moved" 158 REQUEST['RESPONSE'].redirect(target.getPrimaryUrlPath())159 160
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:45 2007 | http://epydoc.sourceforge.net |