1
2
3
4
5
6
7
8
9
10
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
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
42
43
44
45 if 'RESPONSE' in args:
46 del args['RESPONSE']
47
48 m = zenPath('Products/ZenReports/plugins')
49 directories = [
50 p.path('reports', 'plugins') for p in self.ZenPackManager.packs()
51 ] + [m]
52
53 klass = None
54 for d in directories:
55 if os.path.exists('%s/%s.py' % (d, name)):
56 try:
57 sys.path.insert(0, d)
58 klass = importClass(name)
59 break
60 finally:
61 sys.path.remove(d)
62 if not klass:
63 raise IOError('Unable to find plugin named "%s"' % name)
64 instance = klass()
65 return instance.run(dmd, args)
66
73
74
75 InitializeClass(ReportServer)
76