Back to index

plone3  3.1.7
Classes | Functions | Variables
statusmessages.adapter Namespace Reference

Classes

class  StatusMessage

Functions

def _encodeCookieValue
def _decodeCookieValue

Variables

tuple logger = logging.getLogger('statusmessages')

Function Documentation

def statusmessages.adapter._decodeCookieValue (   string) [private]
Decode a cookie value to a list of Messages.

Definition at line 73 of file adapter.py.

00073 
00074 def _decodeCookieValue(string):
00075     """Decode a cookie value to a list of Messages.
00076     """
00077     results = []
00078     # Return nothing if the cookie is marked as deleted
00079     if string == 'deleted':
00080         return results
00081     # Try to decode the cookie value
00082     try:
00083         value = binascii.a2b_base64(string)
00084         while len(value) > 1: # at least 2 bytes of data
00085             message, value = decode(value)
00086             if message is not None:
00087                 results.append(message)
00088     except (binascii.Error, UnicodeEncodeError):
00089         logger.log(logging.ERROR, '%s \n%s',
00090                    'Unexpected value in statusmessages cookie',
00091                    sys.exc_value
00092                    )
00093         return []
00094 
00095     return results

Here is the call graph for this function:

Here is the caller graph for this function:

def statusmessages.adapter._encodeCookieValue (   text,
  type,
  old = None 
) [private]
Encodes text and type to a list of Messages. If there is already some old
   existing list, add the new Message at the end but don't add duplicate
   messages.

Definition at line 57 of file adapter.py.

00057 
00058 def _encodeCookieValue(text, type, old=None):
00059     """Encodes text and type to a list of Messages. If there is already some old
00060        existing list, add the new Message at the end but don't add duplicate
00061        messages.
00062     """
00063     results = []
00064     message = Message(text, type=type)
00065 
00066     if old is not None:
00067         results = _decodeCookieValue(old)
00068     if not message in results:
00069         results.append(message)
00070 
00071     messages = ''.join([r.encode() for r in results])
00072     return binascii.b2a_base64(messages).rstrip()

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

tuple statusmessages.adapter.logger = logging.getLogger('statusmessages')

Definition at line 14 of file adapter.py.