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

Source Code for Module ZenModel.Report

  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__="""Report 
 15   
 16  Report represents a group of devices 
 17   
 18  $Id: Report.py,v 1.3 2004/04/06 02:19:04 edahl Exp $""" 
 19   
 20  __version__ = "$Revision: 1.3 $"[11:-2] 
 21   
 22  from urllib import quote 
 23   
 24  from Globals import DTMLFile 
 25  from Globals import InitializeClass 
 26  from AccessControl import ClassSecurityInfo 
 27   
 28  from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate 
 29  from Products.PageTemplates.PageTemplateFile import PageTemplateFile 
 30   
 31  from ZenModelRM import ZenModelRM 
 32  from ZenPackable import ZenPackable 
 33   
34 -def manage_addReport(context, id, title = None, text=None, 35 REQUEST = None, submit=None):
36 """make a Report""" 37 id = str(id) 38 if REQUEST is None: 39 context._setObject(id, Report(id, text)) 40 ob = getattr(context, id) 41 if title: 42 ob.pt_setTitle(title) 43 return ob 44 else: 45 file = REQUEST.form.get('file') 46 headers = getattr(file, 'headers', None) 47 if headers is None or not file.filename: 48 zpt = Report(id) 49 else: 50 zpt = Report(id, file, headers.get('content_type')) 51 52 context._setObject(id, zpt) 53 54 try: 55 u = context.DestinationURL() 56 except AttributeError: 57 u = REQUEST['URL1'] 58 59 if submit == " Add and Edit ": 60 u = "%s/%s" % (u, quote(id)) 61 REQUEST.RESPONSE.redirect(u+'/manage_main') 62 return ''
63 64 65 addReport = PageTemplateFile('www/reportAdd', globals(), 66 __name__='addReport') 67 68
69 -class Report(ZopePageTemplate, ZenModelRM, ZenPackable):
70 """Report object""" 71 meta_type = 'Report' 72 73 # this is deprecated don't use!!! 74 description = "" 75 76 security = ClassSecurityInfo() 77 78 _relations = ZenPackable._relations 79 80 pt_editForm = PageTemplateFile('www/reportEdit', globals(), 81 __name__='pt_editForm') 82 83
84 - def __init__(self, id, title = None, text=None, content_type=None):
85 ZenModelRM.__init__(self, id); 86 ZopePageTemplate.__init__(self, id, text, content_type) 87 self.title = title
88 89
90 - def om_icons(self):
91 """Return a list of icon URLs to be displayed by an ObjectManager""" 92 icons = ({'path': 'misc_/Confmon/Report_icon.gif', 93 'alt': self.meta_type, 'title': self.meta_type},) 94 if not self._v_cooked: 95 self._cook() 96 if self._v_errors: 97 icons = icons + ({'path': 'misc_/PageTemplates/exclamation.gif', 98 'alt': 'Error', 99 'title': 'This template has an error'},) 100 return icons
101 102 103 InitializeClass(Report) 104