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