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 OFS.SimpleItem import SimpleItem
18 from OFS.PropertyManager import PropertyManager
19 from Products.ZenModel.ZenModelRM import ZenModelRM
20 from Globals import InitializeClass, DevelopmentMode
21
23
25 """
26 Add a portlet.
27 """
28 pass
29
31 """
32 A wrapper for a portlet javascript source file that can include metadata
33 such as a name, a title, a description and permissions.
34
35 Portlets should not be instantiated directly. They should only be created
36 by a PortletManager object.
37 """
38 source = ''
39
40 portal_type = meta_type = 'Portlet'
41
42 _relations = (
43 ("portletManager", ToOne(
44 ToManyCont, "Products.ZenWidgets.PortletManager", "portlets")),
45 )
46
47 _properties = (
48 {'id':'title','type':'string','mode':'w'},
49 {'id':'description', 'type':'string', 'mode':'w'},
50 {'id':'permission', 'type':'string', 'mode':'w'},
51 {'id':'sourcepath', 'type':'string', 'mode':'w'},
52 {'id':'preview', 'type':'string', 'mode':'w'},
53 )
54
55 - def __init__(self, sourcepath, id='', title='', description='',
56 preview='', permission=ZEN_COMMON):
66
68 return exists(self.sourcepath)
69
77
79 if debug_mode: self._read_source()
80 src = []
81 src.append(self.source)
82 src.append("YAHOO.zenoss.portlet.register_portlet('%s', '%s');" % (
83 self.id, self.title))
84 return '\n'.join(src)
85
86 InitializeClass(Portlet)
87