Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
statusmessages.adapter.StatusMessage Class Reference

List of all members.

Public Member Functions

def __init__
def addStatusMessage
def showStatusMessages

Public Attributes

 context

Detailed Description

Adapter for the BrowserRequest to handle status messages.

Let's make sure that this implementation actually fulfills the
'IStatusMessage' API.

  >>> from zope.interface.verify import verifyClass
  >>> verifyClass(IStatusMessage, StatusMessage)
  True

Definition at line 16 of file adapter.py.


Constructor & Destructor Documentation

def statusmessages.adapter.StatusMessage.__init__ (   self,
  context 
)

Definition at line 28 of file adapter.py.

00028 
00029     def __init__(self, context):
00030         self.context = context # the context must be the request


Member Function Documentation

def statusmessages.adapter.StatusMessage.addStatusMessage (   self,
  text,
  type = '' 
)
Add a status message.

Definition at line 31 of file adapter.py.

00031 
00032     def addStatusMessage(self, text, type=''):
00033         """Add a status message.
00034         """
00035         text = translate(text, context=self.context)
00036         annotations = IAnnotations(self.context)
00037 
00038         old = annotations.get(STATUSMESSAGEKEY, self.context.cookies.get(STATUSMESSAGEKEY))
00039         value = _encodeCookieValue(text, type, old=old)
00040         self.context.RESPONSE.setCookie(STATUSMESSAGEKEY, value, path='/')
00041         annotations[STATUSMESSAGEKEY] = value

Here is the call graph for this function:

Removes all status messages and returns them for display.

Definition at line 42 of file adapter.py.

00042 
00043     def showStatusMessages(self):
00044         """Removes all status messages and returns them for display.
00045         """
00046         annotations = IAnnotations(self.context)
00047         value = annotations.get(STATUSMESSAGEKEY, self.context.cookies.get(STATUSMESSAGEKEY))
00048         if value is None:
00049             return []
00050         value = _decodeCookieValue(value)
00051         # clear the existing cookie entries
00052         self.context.cookies[STATUSMESSAGEKEY] = None
00053         self.context.RESPONSE.expireCookie(STATUSMESSAGEKEY, path='/')
00054         annotations[STATUSMESSAGEKEY] = None
00055         return value
00056 

Here is the call graph for this function:


Member Data Documentation

Definition at line 29 of file adapter.py.


The documentation for this class was generated from the following file: