1
2
3
4
5
6
7
8
9
10
11
12
13
14 from Products.ZenModel.ZenossSecurity import *
15 from os.path import basename, exists
16 from Products.ZenRelations.RelSchema import *
17 from Products.ZenModel.ZenModelRM import ZenModelRM
18 from Globals import InitializeClass
19 from Products.ZenUtils.Utils import zenPath
20
21
23 """
24 Add a portlet.
25 """
26 pass
27
29 """
30 A wrapper for a portlet javascript source file that can include metadata
31 such as a name, a title, a description and permissions.
32
33 Portlets should not be instantiated directly. They should only be created
34 by a PortletManager object.
35 """
36 source = ''
37
38 portal_type = meta_type = 'Portlet'
39
40 _relations = (
41 ("portletManager", ToOne(
42 ToManyCont, "Products.ZenWidgets.PortletManager", "portlets")),
43 )
44
45 _properties = (
46 {'id':'title','type':'string','mode':'w'},
47 {'id':'description', 'type':'string', 'mode':'w'},
48 {'id':'permission', 'type':'string', 'mode':'w'},
49 {'id':'sourcepath', 'type':'string', 'mode':'w'},
50 {'id':'preview', 'type':'string', 'mode':'w'},
51 )
52
53 - def __init__(self, sourcepath, id='', title='', description='',
54 preview='', permission=ZEN_COMMON):
64
67
70
79
81 if debug_mode: self._read_source()
82 src = []
83 src.append(self.source)
84 src.append("YAHOO.zenoss.portlet.register_portlet('%s', '%s');" % (
85 self.id, self.title))
86 return '\n'.join(src)
87
88 InitializeClass(Portlet)
89