Back to index

plone3  3.1.7
Classes | Functions
statusmessages.message Namespace Reference

Classes

class  Message

Functions

def _utf8
def _unicode
def decode

Function Documentation

def statusmessages.message._unicode (   value) [private]

Definition at line 15 of file message.py.

00015 
00016 def _unicode(value):
00017     return unicode(value, 'utf-8', 'ignore')
00018 

Here is the caller graph for this function:

def statusmessages.message._utf8 (   value) [private]

Definition at line 8 of file message.py.

00008 
00009 def _utf8(value):
00010     if isinstance(value, unicode):
00011         return value.encode('utf-8')
00012     elif isinstance(value, str):
00013         return value
00014     return ''

Here is the caller graph for this function:

Decode messages from a cookie

We return the decoded message object, and the remainder of the cookie
value (it can contain further messages).

We expect at least 2 bytes (size information).

Definition at line 85 of file message.py.

00085 
00086 def decode(value):
00087     """
00088     Decode messages from a cookie
00089 
00090     We return the decoded message object, and the remainder of the cookie
00091     value (it can contain further messages).
00092 
00093     We expect at least 2 bytes (size information).
00094     """
00095     if len(value) >= 2:
00096         size = struct.unpack('!H', value[:2])[0]
00097         msize, tsize = (size >> 5, size & 31)
00098         message = Message(_unicode(value[2:msize+2]),
00099                           _unicode(value[msize+2:msize+tsize+2]))
00100         return message, value[msize+tsize+2:]
00101     return None, ''

Here is the call graph for this function: