Package ZenReports :: Module ReportServer
[hide private]
[frames] | no frames]

Source Code for Module ZenReports.ReportServer

 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  __doc__="""ReportServer 
14   
15  A front end to all the report plugins. 
16   
17  $Id: $""" 
18   
19  __version__ = "$Revision: $"[11:-2] 
20   
21  from Globals import InitializeClass 
22   
23  from AccessControl import ClassSecurityInfo 
24   
25  from Products.ZenModel.ZenModelRM import ZenModelRM 
26  from Products.ZenUtils.Utils import importClass, zenPath 
27  from Products.ZenModel.ZenossSecurity import * 
28   
29  import os 
30  import sys 
31   
32 -class ReportServer(ZenModelRM):
33 security = ClassSecurityInfo() 34 security.setDefaultAccess('allow') 35 36 security.declareProtected(ZEN_COMMON, 'plugin')
37 - def plugin(self, name, REQUEST):
38 "Run a plugin to generate the report object" 39 dmd = self.dmd 40 args = dict(zip(REQUEST.keys(), REQUEST.values())) 41 m = zenPath('Products/ZenReports/plugins') 42 directories = [ 43 p.path('reports', 'plugins') for p in self.packs() 44 ] + [m] 45 46 klass = None 47 for d in directories: 48 if os.path.exists('%s/%s.py' % (d, name)): 49 try: 50 sys.path.insert(0, d) 51 klass = importClass(name) 52 break 53 finally: 54 sys.path.remove(d) 55 if not klass: 56 raise IOError('Unable to find plugin named "%s"' % name) 57 instance = klass() 58 return instance.run(dmd, args)
59
60 -def manage_addReportServer(context, id, REQUEST = None):
61 """make a ReportServer""" 62 rs = ReportServer(id) 63 context._setObject(id, rs) 64 if REQUEST is not None: 65 REQUEST['RESPONSE'].redirect(context.absolute_url()+'/manage_main')
66 67 68 InitializeClass(ReportServer) 69