webfaction and repo.or.cz deployment done
[worddb.git] / libs / session_messages / __init__.py
bloba48ef74761edce83068eefb21045a4e0e9651503
1 """
2 Lightweight session-based messaging system for use until #4604 finally lands.
4 Time-stamp: <2008-07-19 22:44:56 carljm __init__.py>
6 """
7 VERSION = (0, 1, 'pre')
9 def create_message (request, message):
10 """
11 Create a message in the current session.
13 Return True if message was saved in session, or False if it
14 couldn't be (likely because session framework is not in
15 INSTALLED_APPS).
17 """
18 if hasattr(request, 'session'):
19 try:
20 request.session['messages'].append(message)
21 except KeyError:
22 request.session['messages'] = [message]
23 return True
24 return False
26 def get_and_delete_messages (request):
27 """
28 Get and delete all messages for current session.
30 """
31 if hasattr(request, 'session'):
32 return request.session.pop('messages', [])
33 return []