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
22 """
23 Add a portlet.
24 """
25 pass
26
28 """
29 A wrapper for a portlet javascript source file that can include metadata
30 such as a name, a title, a description and permissions.
31
32 Portlets should not be instantiated directly. They should only be created
33 by a PortletManager object.
34 """
35 source = ''
36
37 portal_type = meta_type = 'Portlet'
38
39 _relations = (
40 ("portletManager", ToOne(
41 ToManyCont, "Products.ZenWidgets.PortletManager", "portlets")),
42 )
43
44 _properties = (
45 {'id':'title','type':'string','mode':'w'},
46 {'id':'description', 'type':'string', 'mode':'w'},
47 {'id':'permission', 'type':'string', 'mode':'w'},
48 {'id':'sourcepath', 'type':'string', 'mode':'w'},
49 {'id':'preview', 'type':'string', 'mode':'w'},
50 )
51
52
53 - def __init__(self, sourcepath, id='', title='', description='',
54 preview='', permission=ZEN_COMMON):
64
67
70
79
81 """
82 Override the default, which doesn't account for things on zport
83 """
84 return ('', 'zport') + super(Portlet, self).getPrimaryPath(fromNode)
85
87 if debug_mode: self._read_source()
88 src = []
89 src.append(self.source)
90 src.append("YAHOO.zenoss.portlet.register_portlet('%s', '%s');" % (
91 self.id, self.title))
92 return '\n'.join(src)
93
94 InitializeClass(Portlet)
95