1
2
3
4
5
6
7
8
9
10
11 __doc__="""Report
12
13 Report represents a report definition loaded from an .rpt file
14
15 $Id: Report.py,v 1.3 2004/04/06 02:19:04 edahl Exp $"""
16
17 __version__ = "$Revision: 1.3 $"[11:-2]
18
19 from urllib import quote
20
21 from Globals import InitializeClass
22 from AccessControl import ClassSecurityInfo
23
24 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
25 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
26
27 from ZenModelRM import ZenModelRM
28 from ZenPackable import ZenPackable
29 from Products.ZenModel.BaseReport import BaseReport
30 from Products.ZenMessaging.audit import audit
31 from Products.ZenUtils.Utils import getDisplayType
32 from Products.ZenUtils.deprecated import deprecated
33
34 @deprecated
35 -def manage_addReport(context, id, title = None, text=None,
36 REQUEST = None, submit=None):
37 """make a Report"""
38 id = str(id)
39 if REQUEST is None:
40 context._setObject(id, Report(id, text))
41 ob = getattr(context, id)
42 if title:
43 ob.pt_setTitle(title)
44 return ob
45 else:
46 file = REQUEST.form.get('file')
47 headers = getattr(file, 'headers', None)
48 if headers is None or not file.filename:
49 zpt = Report(id)
50 else:
51 zpt = Report(id, file, headers.get('content_type'))
52
53 context._setObject(id, zpt)
54
55 audit('UI.Report.Add', zpt.id, title=title, text=text, reportType=getDisplayType(zpt), organizer=context)
56
57 try:
58 u = context.DestinationURL()
59 except AttributeError:
60 u = REQUEST['URL1']
61
62 if submit == " Add and Edit ":
63 u = "%s/%s" % (u, quote(id))
64 REQUEST.RESPONSE.redirect(u+'/manage_main')
65 return ''
66
67
68 addReport = PageTemplateFile('www/reportAdd', globals(),
69 __name__='addReport')
70
71
72 -class Report(BaseReport, ZenPackable):
73 """Report object"""
74
75 __pychecker__ = 'no-override'
76
77 meta_type = 'Report'
78
79
80 description = ""
81
82 security = ClassSecurityInfo()
83
84 _relations = ZenPackable._relations
85
86 - def __init__(self, id, title = None, text=None, content_type='text/html'):
90
92 """Return our rendered template not our default page
93 """
94 if not 'args' in kwargs:
95 kwargs['args'] = args
96 template = self._template.__of__(self)
97 path_info = template.REQUEST['PATH_INFO'].replace(' ', '%20')
98 if (path_info.startswith('/zport/dmd/Reports') and
99 path_info not in template.REQUEST['HTTP_REFERER'] and
100 'adapt=false' not in template.REQUEST['QUERY_STRING']):
101 url = '/zport/dmd/reports#reporttree:'
102 url += path_info.replace('/', '.')
103 template.REQUEST['RESPONSE'].redirect(url)
104 self.auditRunReport()
105 return template.pt_render(extra_context={'options': kwargs})
106
107
112
113
114 - def manage_main(self):
115 """Return the ZMI edit page of our template not ourself
116 """
117 template = self._template.__of__(self)
118 return template.pt_editForm()
119 pt_editForm = manage_main
120
121
122 - def pt_editAction(self, REQUEST, title, text, content_type, expand):
127
128
129 InitializeClass(Report)
130