1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""Software
15
16 Software represents a software vendor's product.
17
18 $Id: Software.py,v 1.5 2003/03/08 18:34:24 edahl Exp $"""
19
20 __version__ = "$Revision: 1.5 $"[11:-2]
21
22 from Globals import DTMLFile
23 from Globals import InitializeClass
24 from AccessControl import ClassSecurityInfo
25
26 from AccessControl import Permissions as permissions
27
28 from Products.ZenRelations.RelSchema import *
29
30 from MEProduct import MEProduct
31 from ZenDate import ZenDate
32
39
40
41 addSoftware = DTMLFile('dtml/addSoftware',globals())
42
43
45 """Software object"""
46 portal_type = meta_type = 'Software'
47
48 procRegex = ""
49 monitorProc = False
50
51 _properties = (
52 {'id':'procRegex', 'type':'string', 'mode':'w'},
53 {'id':'monitorProc', 'type':'boolean', 'mode':'w'},
54 {'id':'installDate', 'type':'date', 'mode':''},
55 )
56
57 _relations = MEProduct._relations + (
58 ("os", ToOne(ToManyCont, "Products.ZenModel.OperatingSystem", "software")),
59 )
60
61 factory_type_information = (
62 {
63 'id' : 'Software',
64 'meta_type' : 'Software',
65 'description' : """Class to manage product information""",
66 'icon' : 'Software_icon.gif',
67 'product' : 'ZenModel',
68 'factory' : 'manage_addSoftware',
69 'immediate_view' : 'viewProductOverview',
70 'actions' :
71 (
72 { 'id' : 'overview'
73 , 'name' : 'Overview'
74 , 'action' : 'viewSoftwareOverview'
75 , 'permissions' : (
76 permissions.view, )
77 },
78 { 'id' : 'viewHistory'
79 , 'name' : 'Modifications'
80 , 'action' : 'viewHistory'
81 , 'permissions' : (
82 permissions.view, )
83 },
84 )
85 },
86 )
87
88 security = ClassSecurityInfo()
89
93
94
100
101
109
110
111 security.declareProtected('Change Device', 'setProduct')
112 - def setProduct(self, productName, manufacturer="Unknown",
113 newProductName="", REQUEST=None, **kwargs):
114 """Set the product class of this software.
115 """
116 if not manufacturer: manufacturer = "Unknown"
117 if newProductName: productName = newProductName
118 prodobj = self.getDmdRoot("Manufacturers").createSoftwareProduct(
119 productName, manufacturer, **kwargs)
120 self.productClass.addRelation(prodobj)
121 if REQUEST:
122 REQUEST['message'] = ("Set Manufacturer %s and Product %s at time:"
123 % (manufacturer, productName))
124 return self.callZenScreen(REQUEST)
125
126
136
137
139 """Return the name of this software (from its softwareClass)
140 """
141 pclass = self.productClass()
142 if pclass: return pclass.name
143 return ""
144
145
147 """Return the version of this software (from its softwareClass)
148 """
149 pclass = self.productClass()
150 if pclass: return pclass.version
151 return ""
152
153
155 """Return the build of this software (from its softwareClass)
156 """
157 pclass = self.productClass()
158 if pclass: return pclass.build
159 return ""
160
161
163 """Return the install date as a DateTime object.
164 """
165 return self._installDate.getDate()
166
167
169 """Return the install date in the form 'YYYY/MM/DD HH:MM:SS'
170 """
171 return self._installDate.getStringSecsResolution()
172
173
175 """Set the install date should be string in form 'YYYY/MM/DD HH:MM:SS'
176 """
177 self._installDate.setDate(value)
178
179
182
183
185 """Return our Device for DeviceResultInt.
186 """
187 return self.os().device()
188
189
190 InitializeClass(Software)
191