Trees | Indices | Help |
|
---|
|
1 ############################################################################## 2 # 3 # Copyright (C) Zenoss, Inc. 2007, all rights reserved. 4 # 5 # This content is made available according to terms specified in 6 # License.zenoss under the directory where your Zenoss product is installed. 7 # 8 ############################################################################## 9 10 11 __doc__="""ReportClass 12 13 ReportClass groups different types of reports together 14 15 $Id: ReportClass.py,v 1.3 2004/04/22 15:33:44 edahl Exp $""" 16 17 __version__ = "$Revision: 1.3 $"[11:-2] 18 19 from AccessControl import ClassSecurityInfo 20 from Globals import InitializeClass 21 from Globals import DTMLFile 22 23 from Organizer import Organizer 24 from ZenPackable import ZenPackable 25 from ZenossSecurity import ZEN_COMMON, ZEN_MANAGE_DMD 26 from Products.ZenRelations.RelSchema import * 27 from Products.ZenUtils.Utils import unused, getDisplayType 28 from Products.ZenWidgets import messaging 29 from Products.ZenMessaging.audit import audit 30 from Products.ZenUtils.deprecated import deprecated34 """make a report class""" 35 dc = ReportClass(id, title) 36 context._setObject(id, dc) 37 38 if REQUEST is not None: 39 audit('UI.Organizer.Add', dc.id, title=title, organizer=context) 40 messaging.IMessageSender(context).sendToBrowser( 41 'Report Organizer Created', 42 'Report organizer %s was created.' % id 43 ) 44 REQUEST['RESPONSE'].redirect(context.absolute_url() + '/manage_main')45 46 addReportClass = DTMLFile('dtml/addReportClass',globals())49 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")183 184 185 186 InitializeClass(ReportClass) 18777 ''' Return all objects that are instances of ReportClass 78 ''' 79 unused(spec) 80 kids = [o for o in self.objectValues() if isinstance(o, ReportClass)] 81 if checkPerm: 82 kids = [kid for kid in kids if self.checkRemotePerm("View", kid)] 83 if sort: 84 kids.sort(key=lambda x: x.primarySortKey()) 85 return kids86 8789 """Return Ids of children within our organizer.""" 90 unused(spec) 91 return [k.id for k in self.children()]92 93 94 security.declareProtected(ZEN_COMMON, "countChildren")96 """Return a count of all our contained children.""" 97 unused(spec) 98 count = len(self.children()) 99 count += sum(child.countChildren() for child in self.children()) 100 return count101 102 107 108 109 security.declareProtected(ZEN_MANAGE_DMD, 'manage_addReportClass')111 """make a report class""" 112 rClass = self.getReportClass() 113 dc = rClass(id, title) 114 self._setObject(id, dc) 115 if REQUEST: 116 audit('UI.Organizer.Add', dc.id, title=title) 117 messaging.IMessageSender(self).sendToBrowser( 118 'Report Organizer Created', 119 'Report organizer %s was created.' % id 120 ) 121 return self.callZenScreen(REQUEST)122 123125 """Return list of report instances. 126 """ 127 reportspec = ('Report','DeviceReport','GraphReport','MultiGraphReport') 128 return [r for r in self.objectValues(spec=reportspec) 129 if self.checkRemotePerm('View', r)]130 131133 """Return a count of all our contained children.""" 134 count = len(self.reports()) 135 count += sum(child.countReports() for child in self.children()) 136 return count137 138 139 security.declareProtected('Manage DMD', 'manage_addGraphReport') 140 @deprecated142 """Add an graph report to this object. 143 """ 144 if id: 145 from Products.ZenModel.GraphReport import GraphReport 146 gr = GraphReport(id) 147 self._setObject(id, gr) 148 if REQUEST: 149 audit('UI.Report.Add', gr.id, reportType=getDisplayType(gr)) 150 messaging.IMessageSender(self).sendToBrowser( 151 'Report Created', 152 'Graph report %s was created.' % id 153 ) 154 return self.callZenScreen(REQUEST)155 156 @deprecated158 """Move a report from here organizer to moveTarget. 159 """ 160 if not moveTarget or not ids: return self() 161 if isinstance(ids, basestring): ids = (ids,) 162 target = self.getOrganizer(moveTarget) 163 for rptname in ids: 164 rpt = self._getOb(rptname) 165 rpt._operation = 1 # moving object state 166 self._delObject(rptname) 167 target._setObject(rptname, rpt) 168 if REQUEST: 169 messaging.IMessageSender(self).sendToBrowser( 170 'Reports Moved', 171 'Reports %s were moved to %s.' % (', '.join(ids), moveTarget) 172 ) 173 REQUEST['RESPONSE'].redirect(target.getPrimaryUrlPath())174 175
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1.1812 on Mon Jul 30 17:11:18 2012 | http://epydoc.sourceforge.net |