1
2
3
4
5
6
7
8
9
10
11
12
13
14 import re
15 import types
16 import logging
17 log = logging.getLogger("zen.OSProcessOrganizer")
18
19 from Globals import DTMLFile
20 from Globals import InitializeClass
21 from AccessControl import ClassSecurityInfo
22 from AccessControl import Permissions
23 from Acquisition import aq_base
24 from Commandable import Commandable
25 from Products.ZenRelations.RelSchema import *
26 from ZenPackable import ZenPackable
27
28 from Organizer import Organizer
29 from OSProcessClass import OSProcessClass
30
38
39 addOSProcessOrganizer = DTMLFile('dtml/addOSProcessOrganizer',globals())
40
42 meta_type = "OSProcessOrganizer"
43 dmdRootName = "Processes"
44
45
46 description = ""
47
48 _properties = (
49 {'id':'description', 'type':'text', 'mode':'w'},
50 )
51
52 _relations = Organizer._relations + ZenPackable._relations + (
53 ("osProcessClasses", ToManyCont(
54 ToOne,"Products.ZenModel.OSProcessClass","osProcessOrganizer")),
55 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
56 )
57
58 factory_type_information = (
59 {
60 'immediate_view' : 'osProcessOrganizerOverview',
61 'actions' :
62 (
63 { 'id' : 'classes'
64 , 'name' : 'Classes'
65 , 'action' : 'osProcessOrganizerOverview'
66 , 'permissions' : (
67 Permissions.view, )
68 },
69 { 'id' : 'resequence'
70 , 'name' : 'Sequence'
71 , 'action' : 'osProcessResequence'
72 , 'permissions' : (
73 Permissions.view, )
74 },
75 { 'id' : 'manage'
76 , 'name' : 'Administration'
77 , 'action' : 'osProcessOrganizerManage'
78 , 'permissions' : ("Manage DMD",)
79 },
80 { 'id' : 'zproperties'
81 , 'name' : 'zProperties'
82 , 'action' : 'zPropertyEdit'
83 , 'permissions' : ("Change Device",)
84 },
85 { 'id' : 'viewHistory'
86 , 'name' : 'Modifications'
87 , 'action' : 'viewHistory'
88 , 'permissions' : (
89 Permissions.view, )
90 },
91 )
92 },
93 )
94
95 security = ClassSecurityInfo()
96
102
103
105 """Return a list of hashs that define the screen tabs for this object.
106 [{'name':'Name','action':'template','selected':False},...]
107 """
108 tabs = Organizer.zentinelTabs(self, templateName)
109 if self.getPrimaryId() != '/zport/dmd/Processes':
110 tabs = [t for t in tabs if t['id'] != 'resequence']
111 return tabs
112
113
115 """Return generator that goes through all process classes.
116 """
117 for proc in self.osProcessClasses.objectValuesGen():
118 yield proc
119 for subgroup in self.children():
120 for proc in subgroup.getSubOSProcessClassesGen():
121 yield proc
122
123
125 '''Return list of the process classes sorted by sequence.
126 '''
127 def cmpProc(a, b):
128 return cmp(a.sequence, b.sequence)
129 procs = list(self.getSubOSProcessClassesGen())
130 procs.sort(cmpProc)
131 for i, p in enumerate(procs):
132 p.sequence = i
133 return procs
134
135
143
144
156
157
163
166
167
169 """Remove OSProcessClasses from an EventClass.
170 """
171 if not ids: return self()
172 if type(ids) == types.StringType: ids = (ids,)
173 for id in ids:
174 svc = self.osProcessClasses._getOb(id)
175 svc.setZenProperty("zMonitor", monitor)
176 if REQUEST: return self()
177
178
192
193
207
208
215
216
218 ''' Called by Commandable.doCommand() to ascertain objects on which
219 a UserCommand should be executed.
220 '''
221 targets = []
222 for osc in self.osProcessClasses():
223 targets += osc.getUserCommandTargets()
224 for org in self.children():
225 targets += org.getUserCommandTargets()
226 return targets
227
228
231
232
233 InitializeClass(OSProcessOrganizer)
234