Package ZenModel :: Module ClassifierEntry
[hide private]
[frames] | no frames]

Source Code for Module ZenModel.ClassifierEntry

  1  ########################################################################### 
  2  # 
  3  # This program is part of Zenoss Core, an open source monitoring platform. 
  4  # Copyright (C) 2007, Zenoss Inc. 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify it 
  7  # under the terms of the GNU General Public License version 2 as published by 
  8  # the Free Software Foundation. 
  9  # 
 10  # For complete information please visit: http://www.zenoss.com/oss/ 
 11  # 
 12  ########################################################################### 
 13   
 14  __doc__="""ClassifierEntry 
 15   
 16  Contains a list of keywords that are used to match an entry to a specific 
 17  device.  Once a match is found the Entry provides paths for DeviceClass, 
 18  Product, and Company.  This could potentially also provide Location, System 
 19  Group etc. 
 20   
 21  $Id: ClassifierEntry.py,v 1.6 2004/03/26 23:58:44 edahl Exp $""" 
 22   
 23  __version__ = "$Revision: 1.6 $"[11:-2] 
 24   
 25  from AccessControl import ClassSecurityInfo 
 26  from Globals import DTMLFile 
 27   
 28  from Products.ZCatalog.CatalogAwareness import CatalogAware 
 29  from OFS.SimpleItem import SimpleItem 
 30  from OFS.PropertyManager import PropertyManager 
 31   
 32   
33 -def manage_addClassifierEntry(context, id=None, title=None, 34 default_catalog = "", keywords = "", deviceClassPath = "", 35 product = "", systemPath = "", 36 locationPath = "", manufacturer = "", 37 productDescr = "", REQUEST = None):
38 """make a device""" 39 if not id: 40 id = context.ZenClassifier.getNextClassifierEntryId() 41 ce = ClassifierEntry(id, title=title, 42 default_catalog=default_catalog, 43 keywords=keywords, deviceClassPath=deviceClassPath, 44 product=product, systemPath=systemPath, 45 locationPath=locationPath, manufacturer=manufacturer, 46 productDescr = productDescr) 47 context._setObject(id, ce) 48 ce = context._getOb(id) 49 50 if REQUEST is not None: 51 REQUEST['RESPONSE'].redirect(context.absolute_url() 52 +'/manage_main')
53 54 55 addClassifierEntry = DTMLFile('dtml/addClassifierEntry',globals()) 56
57 -class ClassifierEntry(PropertyManager, CatalogAware, SimpleItem):
58 """ClassifierEntry""" 59 60 meta_type = 'ClassifierEntry' 61 62 manage_options = (PropertyManager.manage_options + 63 SimpleItem.manage_options 64 ) 65 66 _properties = ( 67 {'id':'default_catalog', 'type':'selection', 68 'select_variable':'getClassifierNames'}, 69 {'id':'keywords', 'type':'text', 'mode':'rw'}, 70 {'id':'deviceClassPath', 'type':'string', 'mode':'rw'}, 71 {'id':'manufacturer', 'type':'string', 'mode':'rw'}, 72 {'id':'product', 'type':'string', 'mode':'rw'}, 73 {'id':'productDescr', 'type':'text', 'mode':'rw'}, 74 ) 75 76 77 security = ClassSecurityInfo() 78
79 - def __init__(self, id, title=None, 80 default_catalog = "", keywords = "", deviceClassPath = "", 81 product = "", systemPath = "", 82 locationPath = "", manufacturer = "", 83 snmpAgentPath = "", productDescr = ""):
84 from Products.ZenUtils.Utils import unused 85 unused(locationPath) 86 self.id = id 87 self.title = title 88 self.default_catalog = default_catalog 89 self.keywords = keywords 90 self.deviceClassPath = deviceClassPath 91 self.product = product 92 self.productDescr = productDescr 93 self.systemPath = systemPath 94 self.snmpAgentPath = snmpAgentPath 95 self.manufacturer = manufacturer
96 97 98
99 - def manage_editProperties(self, REQUEST):
100 """ Added indexing call -EAD 101 Edit object properties via the web. 102 The purpose of this method is to change all property values, 103 even those not listed in REQUEST; otherwise checkboxes that 104 get turned off will be ignored. Use manage_changeProperties() 105 instead for most situations. 106 """ 107 for prop in self._propertyMap(): 108 name=prop['id'] 109 if 'w' in prop.get('mode', 'wd'): 110 value=REQUEST.get(name, '') 111 if name == 'default_catalog' and self.default_catalog != value: 112 self.unindex_object() 113 self._updateProperty(name, value) 114 self.index_object() 115 if REQUEST: 116 message="Saved changes." 117 return self.manage_propertiesForm(self,REQUEST, 118 manage_tabs_message=message)
119 120
121 - def _url(self):
122 return "/".join(self.getPhysicalPath())
123 124
125 - def index_object(self):
126 """Override so that we can find the catalog no matter where we are 127 A common method to allow Findables to index themselves.""" 128 if hasattr(self.ZenClassifier, self.default_catalog): 129 cat = getattr(self.ZenClassifier, self.default_catalog) 130 cat.catalog_object(self, self._url())
131 132
133 - def unindex_object(self):
134 """Override so that we can find the catalog no matter where we are 135 A common method to allow Findables to unindex themselves.""" 136 if hasattr(self.ZenClassifier, self.default_catalog): 137 cat = getattr(self.ZenClassifier, self.default_catalog) 138 cat.uncatalog_object(self._url())
139 140
141 - def getClassifierNames(self):
142 """allow select in property manager to find ZenClassifier""" 143 return self.ZenClassifier.getClassifierNames()
144 145
146 - def getKeywords(self):
147 """base class just returns attribute mobile subclass returns 148 a concatination of all keyword values up its aquisition path""" 149 return self.keywords
150 151
152 - def getDeviceClassPath(self):
153 """base class just returns attribute mobile subclass returns 154 builds its path based on its current aquisition path""" 155 return self.deviceClassPath
156 157
158 - def getProduct(self):
159 """return the product path for this classifier entry""" 160 return self.product
161 162
163 - def getManufacturer(self):
164 """return the manufacturer for this classifier entry""" 165 return self.manufacturer
166
167 - def getProductDescr(self):
168 """return the productDescr for this classifier entry""" 169 return self.productDescr
170