Package ZenEvents :: Module ZEvent
[hide private]
[frames] | no frames]

Source Code for Module ZenEvents.ZEvent

 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  import cgi 
15  import urllib 
16   
17  from Globals import InitializeClass 
18  from AccessControl import ClassSecurityInfo 
19   
20  from Event import Event 
21   
22 -class ZEvent(Event):
23 """ 24 Event that lives in the zope context has zope security mechanisms and 25 url back to event manager 26 """ 27 security = ClassSecurityInfo() 28 security.setDefaultAccess("allow") 29
30 - def __init__(self, manager, fields, data):
31 Event.__init__(self) 32 self.updateFromFields(fields, data) 33 self._zem = manager.getId() 34 self._baseurl = manager.absolute_url_path()
35
36 - def getDataForJSON(self, fields):
37 """ returns data ready for serialization 38 """ 39 return self.getDataListWithLinks(list(fields)+['evid'])
40 62 63
64 - def getEventDetailHref(self):
65 """build an href to call the detail of this event""" 66 return "%s/viewEventFields?evid=%s" % (self._baseurl, self.evid)
67 68
69 - def getCssClass(self):
70 """return the css class name to be used for this event. 71 """ 72 value = self.severity < 0 and "unknown" or self.severity 73 acked = self.eventState > 0 and "acked" or "noack" 74 return "zenevents_%s_%s %s" % (value, acked, acked)
75
76 - def zem(self):
77 """return the id of our manager. 78 """ 79 return self._zem
80 81 InitializeClass(ZEvent) 82