1
2
3
4
5
6
7
8
9
10
11 __doc__ = """
12 This is in a separate module to prevent recursive import.
13 """
14
15 import time
16 from zope.interface import implements
17
18 from Products.ZenModel.ZenModelRM import ZenModelRM
19 from Products.ZenRelations.RelSchema import *
20 from Products.ZenWidgets.interfaces import IMessage
21 from Products.ZenWidgets.messaging import INFO
22
24 """
25 A single message. Messages are stored as relations on UserSettings and in
26 the session object.
27 """
28 implements(IMessage)
29
30 _relations = (("messageQueue", ToOne(
31 ToManyCont, "Products.ZenModel.UserSettings.UserSettings", "messages")
32 ),)
33
34 title = None
35 body = None
36 timestamp = None
37 priority = None
38 _read = False
39
40 - def __init__(self, id, title, body, priority=INFO, image=None):
41 """
42 Initialization method.
43
44 @param title: The message title
45 @type title: str
46 @param body: The body of the message
47 @type body: str
48 @param priority: Message priority; one of INFO, WARNING, CRITICAL
49 @type priority: int
50 @param image: Optional URL of an image to be displayed in the message
51 @type image: str
52 """
53 super(PersistentMessage, self).__init__(id)
54 self.title = title
55 self.body = body
56 self.priority = priority
57 self.image = image
58 self.timestamp = time.time()
59
61 """
62 Mark this message as read.
63 """
64 self._read = True
65
67 """
68 Delete this message from the system.
69 """
70 self.__primary_parent__._delObject(self.id)
71