1
2
3
4
5
6
7
8
9
10
11 from Globals import InitializeClass
12 from AccessControl import ClassSecurityInfo
13
14 from ManagedEntity import ManagedEntity
15
16 from Products.ZenRelations.RelSchema import *
17
19 """
20 MEProduct is a ManagedEntity that needs to track is manufacturer.
21 For instance software and hardware.
22 """
23
24 _prodKey = None
25 _manufacturer = None
26
27 _relations = ManagedEntity._relations + (
28 ("productClass", ToOne(ToMany, "Products.ZenModel.ProductClass", "instances")),
29 )
30
31 security = ClassSecurityInfo()
32
33
34 security.declareProtected('View', 'getProductName')
36 """
37 Gets the Products's Name (id)
38 """
39 productClass = self.productClass()
40 if productClass:
41 return productClass.titleOrId()
42 return ''
43 getModelName = getProductName
44
45
46 security.declareProtected('View', 'getProductHref')
48 """
49 Gets the Products's PrimaryHref
50 """
51 productClass = self.productClass()
52 if productClass:
53 return productClass.getPrimaryHref()
54 return ''
55
56
57 security.declareProtected('View', 'getManufacturer')
59 if self.productClass():
60 return self.productClass().manufacturer()
61
62
63 security.declareProtected('View', 'getManufacturerName')
65 """
66 Gets the Manufacturer Name(Id)
67 """
68 manuf = self.getManufacturer()
69 if manuf: return manuf.titleOrId()
70 return ""
71
72
73 security.declareProtected('View', 'getManufacturerLink')
75 """
76 Gets the Manufacturer PrimaryLink
77 """
78 if self.productClass():
79 return self.productClass().manufacturer.getPrimaryLink(target)
80 return ""
81
82
83 security.declareProtected('View', 'getManufacturerLink')
85 """
86 Gets the Manufacturer's PrimaryHref
87 """
88 if self.productClass():
89 return self.productClass().manufacturer.getPrimaryHref()
90 return ""
91
92
94 """
95 Return the arguments to the setProductKey method so we can avoid
96 changing the object model when nothing has changed.
97 """
98 if self.productClass() is None:
99 return ""
100 elif self._manufacturer is not None:
101 return (self._prodKey, self._manufacturer)
102 elif self._prodKey is not None:
103 return self._prodKey
104 else:
105 pclass = self.productClass()
106 return pclass.getProductKey()
107
109 """
110 Gets the Product's PrimaryLink
111 """
112 return self.productClass.getPrimaryLink(target)
113
114
116 """Return list of tuples with product context for this product.
117 """
118 prod = self.productClass()
119 if prod:
120 prodcontext = self.primaryAq()
121 return prodcontext.zenPropertyItems()
122 return []
123
124
126 """
127 Sets the description of the underlying ProductClass
128 """
129
130 prod = self.productClass()
131
132 if prod:
133 prod.description = description
134
135
137 """
138 Gets the description of the underlying ProductClass
139 """
140
141 prod = self.productClass()
142
143 if prod: result = prod.description
144 else : result = None
145
146 return result
147
148
151
152 InitializeClass(MEProduct)
153