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' : 'Configuration Properties'
86 , 'action' : 'zPropertyEditNew'
87 , 'permissions' : ("Manage DMD",)
88 },
89 )
90 },
91 )
92
93 security = ClassSecurityInfo()
94
95
96 - def __init__(self, id, title="", prodName=None,
97 productKey=None, partNumber="",description=""):
113
114
116 """Return the type name of this product (Hardware, Software).
117 """
118 return self.meta_type[:-5]
119
120
122 """Return the number of existing instances for this class.
123 """
124 return self.instances.countObjects()
125
126
128 """Return the first product key of the device.
129 """
130 if len(self.productKeys) > 0:
131 return self.productKeys[0]
132 return ""
133
134
136 if not self.manufacturer():
137 return ''
138 return self.manufacturer().getId()
139
140
141 security.declareProtected('Manage DMD', 'manage_editProductClass')
142 - def manage_editProductClass(self, name="", productKeys=(), isOS=False,
143 partNumber="", description="", REQUEST=None):
164
165
166 InitializeClass(ProductClass)
167