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 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
66
67
68 InitializeClass(ReportServer)
69