Package Products :: Package ZenModel :: Module MEProduct
[hide private]
[frames] | no frames]

Source Code for Module Products.ZenModel.MEProduct

  1  ############################################################################## 
  2  #  
  3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved. 
  4  #  
  5  # This content is made available according to terms specified in 
  6  # License.zenoss under the directory where your Zenoss product is installed. 
  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   
18 -class MEProduct(ManagedEntity):
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')
35 - def getProductName(self):
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')
47 - def getProductHref(self):
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')
58 - def getManufacturer(self):
59 if self.productClass(): 60 return self.productClass().manufacturer()
61 62 63 security.declareProtected('View', 'getManufacturerName')
64 - def getManufacturerName(self):
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') 81 82 83 security.declareProtected('View', 'getManufacturerLink')
84 - def getManufacturerHref(self):
85 """ 86 Gets the Manufacturer's PrimaryHref 87 """ 88 if self.productClass(): 89 return self.productClass().manufacturer.getPrimaryHref() 90 return ""
91 92
93 - def getProductKey(self):
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 113 114
115 - def getProductContext(self):
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
125 - def setDescription(self, description):
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
136 - def getDescription(self):
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