1
2
3
4
5
6
7
8
9
10
11 __doc__="""ProductClass
12
13 The product classification class. default identifiers, screens,
14 and data collectors live here.
15
16 $Id: ProductClass.py,v 1.10 2004/03/26 23:58:44 edahl Exp $"""
17
18 __version__ = "$Revision: 1.10 $"[11:-2]
19
20 from Globals import InitializeClass
21 from AccessControl import ClassSecurityInfo
22 from AccessControl import Permissions as permissions
23 from zope.interface import implements
24
25 from Products.ZenModel.interfaces import IIndexed
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 implements(IIndexed)
36 meta_type = "ProductClass"
37
38
39 name = ""
40 productKeys = []
41 isOS = False
42
43 default_catalog = "productSearch"
44
45 _properties = (
46
47 {'id':'name', 'type':'string', 'mode':'w'},
48 {'id':'productKeys', 'type':'lines', 'mode':'w'},
49 {'id':'partNumber', 'type':'string', 'mode':'w'},
50 {'id':'description', 'type':'string', 'mode':'w'},
51 {'id':'isOS', 'type':'boolean', 'mode':'w'},
52 )
53
54 _relations = ZenPackable._relations + (
55 ("instances", ToMany(ToOne, "Products.ZenModel.MEProduct", "productClass")),
56 ("manufacturer", ToOne(ToManyCont,"Products.ZenModel.Manufacturer","products")),
57 )
58
59 factory_type_information = (
60 {
61 'id' : 'ProductClass',
62 'meta_type' : 'ProductClass',
63 'description' : """Class to manage product information""",
64 'icon' : 'ProductClass.gif',
65 'product' : 'ZenModel',
66 'factory' : 'manage_addProductClass',
67 'immediate_view' : 'viewProductClassOverview',
68 'actions' :
69 (
70 { 'id' : 'overview'
71 , 'name' : 'Overview'
72 , 'action' : 'viewProductClassOverview'
73 , 'permissions' : (
74 permissions.view, )
75 },
76 { 'id' : 'edit'
77 , 'name' : 'Edit'
78 , 'action' : 'editProductClass'
79 , 'permissions' : ("Manage DMD", )
80 },
81 { 'id' : 'config'
82 , 'name' : 'Configuration Properties'
83 , 'action' : 'zPropertyEditNew'
84 , 'permissions' : ("Manage DMD",)
85 },
86 )
87 },
88 )
89
90 security = ClassSecurityInfo()
91
92
93 - def __init__(self, id, title="", prodName=None,
94 productKey=None, partNumber="",description=""):
110
111
113 """Return the type name of this product (Hardware, Software).
114 """
115 return self.meta_type[:-5]
116
117
119 """Return the number of existing instances for this class.
120 """
121 return self.instances.countObjects()
122
123
125 """Return the first product key of the device.
126 """
127 if len(self.productKeys) > 0:
128 return self.productKeys[0]
129 return ""
130
131
133 if not self.manufacturer():
134 return ''
135 return self.manufacturer().getId()
136
137
138 security.declareProtected('Manage DMD', 'manage_editProductClass')
139 - def manage_editProductClass(self, name="", productKeys=(), isOS=False,
140 partNumber="", description="", REQUEST=None):
161
162
163 InitializeClass(ProductClass)
164