1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""ProductClass
15
16 The product classification class. default identifiers, screens,
17 and data collectors live here.
18
19 $Id: ProductClass.py,v 1.10 2004/03/26 23:58:44 edahl Exp $"""
20
21 __version__ = "$Revision: 1.10 $"[11:-2]
22
23 from Globals import InitializeClass
24 from AccessControl import ClassSecurityInfo
25 from AccessControl import Permissions as permissions
26 from Products.ZenModel.ZenossSecurity import *
27 from Products.ZenWidgets import messaging
28
29 from ZenModelRM import ZenModelRM
30 from ZenPackable import ZenPackable
31
32 from Products.ZenRelations.RelSchema import *
33
35
36
37 meta_type = "ProductClass"
38
39
40 name = ""
41 productKeys = []
42 isOS = False
43
44 default_catalog = "productSearch"
45
46 _properties = (
47
48 {'id':'name', 'type':'string', 'mode':'w'},
49 {'id':'productKeys', 'type':'lines', 'mode':'w'},
50 {'id':'partNumber', 'type':'string', 'mode':'w'},
51 {'id':'description', 'type':'string', 'mode':'w'},
52 {'id':'isOS', 'type':'boolean', 'mode':'w'},
53 )
54
55 _relations = ZenPackable._relations + (
56 ("instances", ToMany(ToOne, "Products.ZenModel.MEProduct", "productClass")),
57 ("manufacturer", ToOne(ToManyCont,"Products.ZenModel.Manufacturer","products")),
58 )
59
60 factory_type_information = (
61 {
62 'id' : 'ProductClass',
63 'meta_type' : 'ProductClass',
64 'description' : """Class to manage product information""",
65 'icon' : 'ProductClass.gif',
66 'product' : 'ZenModel',
67 'factory' : 'manage_addProductClass',
68 'immediate_view' : 'viewProductClassOverview',
69 'actions' :
70 (
71 { 'id' : 'overview'
72 , 'name' : 'Overview'
73 , 'action' : 'viewProductClassOverview'
74 , 'permissions' : (
75 permissions.view, )
76 },
77 { 'id' : 'edit'
78 , 'name' : 'Edit'
79 , 'action' : 'editProductClass'
80 , 'permissions' : ("Manage DMD", )
81 },
82 { 'id' : 'config'
83 , 'name' : 'zProperties'
84 , 'action' : 'zPropertyEdit'
85 , 'permissions' : ("Manage DMD",)
86 },
87 { 'id' : 'viewHistory'
88 , 'name' : 'Modifications'
89 , 'action' : 'viewHistory'
90 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,)
91 },
92 )
93 },
94 )
95
96 security = ClassSecurityInfo()
97
98
99 - def __init__(self, id, title="", prodName=None,
100 productKey=None, partNumber="",description=""):
116
117
119 """Return the type name of this product (Hardware, Software).
120 """
121 return self.meta_type[:-5]
122
123
125 """Return the number of existing instances for this class.
126 """
127 return self.instances.countObjects()
128
129
131 """Return the first product key of the device.
132 """
133 if len(self.productKeys) > 0:
134 return self.productKeys[0]
135 return ""
136
137
139 if not self.manufacturer():
140 return ''
141 return self.manufacturer().getId()
142
143
150
151
156
157
165
166
167 security.declareProtected('Manage DMD', 'manage_editProductClass')
168 - def manage_editProductClass(self, name="", productKeys=(), isOS=False,
169 partNumber="", description="", REQUEST=None):
190
191
192 InitializeClass(ProductClass)
193