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 Globals import DTMLFile 27 28 from Organizer import Organizer 29 from ZenPackable import ZenPackable 30 from ZenossSecurity import ZEN_COMMON, ZEN_MANAGE_DMD 31 from Products.ZenRelations.RelSchema import * 32 from Products.ZenUtils.Utils import unused 33 from Products.ZenWidgets import messaging 3436 """make a device class""" 37 dc = ReportClass(id, title) 38 context._setObject(id, dc) 39 40 if REQUEST is not None: 41 messaging.IMessageSender(context).sendToBrowser( 42 'Report Organizer Created', 43 'Report organizer %s was created.' % id 44 ) 45 REQUEST['RESPONSE'].redirect(context.absolute_url() + '/manage_main')46 47 addReportClass = DTMLFile('dtml/addReportClass',globals()) 4850 dmdRootName = "Reports" 51 portal_type = meta_type = "ReportClass" 52 53 #sub_meta_types = ("ReportClass", "Report", 'DeviceReport', 'GraphReport', 54 # 'MultiGraphReportClass') 55 56 _relations = Organizer._relations + ZenPackable._relations 57 58 # Screen action bindings (and tab definitions) 59 factory_type_information = ( 60 { 61 'immediate_view' : 'viewReportClass', 62 'actions' : 63 ( 64 { 'id' : 'view' 65 , 'name' : 'Status' 66 , 'action' : 'viewReportClass' 67 , 'permissions' : ( "View",) 68 , 'visible' : 1 69 }, 70 ) 71 }, 72 ) 73 74 security = ClassSecurityInfo() 75 76 security.declareProtected(ZEN_COMMON, "children")186 187 188 189 InitializeClass(ReportClass) 19078 ''' Return all objects that are instances of ReportClass 79 ''' 80 unused(spec) 81 kids = [o for o in self.objectValues() if isinstance(o, ReportClass)] 82 if checkPerm: 83 kids = [kid for kid in kids if self.checkRemotePerm("View", kid)] 84 if sort: kids.sort(lambda x,y: cmp(x.primarySortKey(), 85 y.primarySortKey())) 86 return kids87 8890 """Return Ids of children within our organizer.""" 91 unused(spec) 92 return [k.id for k in self.children()]93 94 95 security.declareProtected(ZEN_COMMON, "countChildren")97 """Return a count of all our contained children.""" 98 unused(spec) 99 count = len(self.childIds()) 100 for child in self.children(): 101 count += child.countChildren() 102 return count103 104 109 110 111 security.declareProtected(ZEN_MANAGE_DMD, 'manage_addReportClass')113 """make a device class""" 114 rClass = self.getReportClass() 115 dc = rClass(id, title) 116 self._setObject(id, dc) 117 if REQUEST: 118 messaging.IMessageSender(self).sendToBrowser( 119 'Report Organizer Created', 120 'Report organizer %s was created.' % id 121 ) 122 return self.callZenScreen(REQUEST)123 124126 """Return list of report instances. 127 """ 128 reports = [] 129 for r in self.objectValues( 130 spec=('Report','DeviceReport','GraphReport','MultiGraphReport')): 131 if self.checkRemotePerm('View', r): 132 reports.append(r) 133 return reports134 135137 """Return a count of all our contained children.""" 138 count = len(self.reports()) 139 for child in self.children(): 140 count += child.countReports() 141 return count142 143 144 security.declareProtected('Manage DMD', 'manage_addGraphReport')146 """Add an graph report to this object. 147 """ 148 if id: 149 from Products.ZenModel.GraphReport import GraphReport 150 gr = GraphReport(id) 151 self._setObject(id, gr) 152 if REQUEST: 153 messaging.IMessageSender(self).sendToBrowser( 154 'Report Created', 155 'Graph report %s was created.' % id 156 ) 157 return self.callZenScreen(REQUEST)158 159161 """Move a report from here organizer to moveTarget. 162 """ 163 if not moveTarget or not ids: return self() 164 if type(ids) in types.StringTypes: ids = (ids,) 165 target = self.getOrganizer(moveTarget) 166 for rptname in ids: 167 rpt = self._getOb(rptname) 168 rpt._operation = 1 # moving object state 169 self._delObject(rptname) 170 target._setObject(rptname, rpt) 171 if REQUEST: 172 messaging.IMessageSender(self).sendToBrowser( 173 'Reports Moved', 174 'Reports %s were moved to %s.' % (', '.join(ids), moveTarget) 175 ) 176 REQUEST['RESPONSE'].redirect(target.getPrimaryUrlPath())177 178
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Jul 14 12:07:29 2010 | http://epydoc.sourceforge.net |