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