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  from Globals import Persistent 
 28  from Globals import InitializeClass 
 29   
 30  from Products.ZCatalog.CatalogAwareness import CatalogAware 
 31  from OFS.SimpleItem import SimpleItem 
 32  from OFS.PropertyManager import PropertyManager 
 33   
 34   
35 -def manage_addClassifierEntry(context, id=None, title=None, 36 default_catalog = "", keywords = "", deviceClassPath = "", 37 product = "", systemPath = "", 38 locationPath = "", manufacturer = "", 39 productDescr = "", REQUEST = None):
40 """make a device""" 41 if not id: 42 id = context.ZenClassifier.getNextClassifierEntryId() 43 ce = ClassifierEntry(id, title=title, 44 default_catalog=default_catalog, 45 keywords=keywords, deviceClassPath=deviceClassPath, 46 product=product, systemPath=systemPath, 47 locationPath=locationPath, manufacturer=manufacturer, 48 productDescr = productDescr) 49 context._setObject(id, ce) 50 ce = context._getOb(id) 51 52 if REQUEST is not None: 53 REQUEST['RESPONSE'].redirect(context.absolute_url() 54 +'/manage_main')
55 56 57 addClassifierEntry = DTMLFile('dtml/addClassifierEntry',globals()) 58
59 -class ClassifierEntry(PropertyManager, CatalogAware, SimpleItem):
60 """ClassifierEntry""" 61 62 meta_type = 'ClassifierEntry' 63 64 manage_options = (PropertyManager.manage_options + 65 SimpleItem.manage_options 66 ) 67 68 _properties = ( 69 {'id':'default_catalog', 'type':'selection', 70 'select_variable':'getClassifierNames'}, 71 {'id':'keywords', 'type':'text', 'mode':'rw'}, 72 {'id':'deviceClassPath', 'type':'string', 'mode':'rw'}, 73 {'id':'manufacturer', 'type':'string', 'mode':'rw'}, 74 {'id':'product', 'type':'string', 'mode':'rw'}, 75 {'id':'productDescr', 'type':'text', 'mode':'rw'}, 76 ) 77 78 79 security = ClassSecurityInfo() 80
81 - def __init__(self, id, title=None, 82 default_catalog = "", keywords = "", deviceClassPath = "", 83 product = "", systemPath = "", 84 locationPath = "", manufacturer = "", 85 snmpAgentPath = "", productDescr = ""):
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