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
27 from ZenModelRM import ZenModelRM
28 from ZenPackable import ZenPackable
29
30 from Products.ZenRelations.RelSchema import *
31
33
34
35 meta_type = "ProductClass"
36
37
38 name = ""
39 productKeys = []
40 isOS = False
41
42 default_catalog = "productSearch"
43
44 _properties = (
45
46 {'id':'name', 'type':'string', 'mode':'w'},
47 {'id':'productKeys', 'type':'lines', 'mode':'w'},
48 {'id':'partNumber', 'type':'string', 'mode':'w'},
49 {'id':'description', 'type':'string', 'mode':'w'},
50 {'id':'isOS', 'type':'boolean', 'mode':'w'},
51 )
52
53 _relations = ZenPackable._relations + (
54 ("instances", ToMany(ToOne, "Products.ZenModel.MEProduct", "productClass")),
55 ("manufacturer", ToOne(ToManyCont,"Products.ZenModel.Manufacturer","products")),
56 )
57
58 factory_type_information = (
59 {
60 'id' : 'ProductClass',
61 'meta_type' : 'ProductClass',
62 'description' : """Class to manage product information""",
63 'icon' : 'ProductClass.gif',
64 'product' : 'ZenModel',
65 'factory' : 'manage_addProductClass',
66 'immediate_view' : 'viewProductClassOverview',
67 'actions' :
68 (
69 { 'id' : 'overview'
70 , 'name' : 'Overview'
71 , 'action' : 'viewProductClassOverview'
72 , 'permissions' : (
73 permissions.view, )
74 },
75 { 'id' : 'edit'
76 , 'name' : 'Edit'
77 , 'action' : 'editProductClass'
78 , 'permissions' : ("Manage DMD", )
79 },
80 { 'id' : 'config'
81 , 'name' : 'zProperties'
82 , 'action' : 'zPropertyEdit'
83 , 'permissions' : ("Manage DMD",)
84 },
85 { 'id' : 'viewHistory'
86 , 'name' : 'Modifications'
87 , 'action' : 'viewHistory'
88 , 'permissions' : (
89 permissions.view, )
90 },
91 )
92 },
93 )
94
95 security = ClassSecurityInfo()
96
97
98 - def __init__(self, id, title="", prodName=None,
99 productKey=None, partNumber="",description=""):
115
116
118 """Return the type name of this product (Hardware, Software).
119 """
120 return self.meta_type[:-5]
121
122
124 """Return the number of existing instances for this class.
125 """
126 return self.instances.countObjects()
127
128
130 """Return the first product key of the device.
131 """
132 if len(self.productKeys) > 0:
133 return self.productKeys[0]
134 return ""
135
136
143
144
149
150
158
159
160 security.declareProtected('Manage DMD', 'manage_editProductClass')
179
180
181 InitializeClass(ProductClass)
182