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