HG changeset patch User Alexander Solovyov piranha piranha org ua Date

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# HG changeset patch
# User Alexander Solovyov <piranha@piranha.org.ua>
# Date 1231672472 -7200
# Node ID 529e6c8e8e2e00b074f2e40146b759604de4274d
# Parent ed64e667f63d2e3989f4470b3cb187b1bc5653b8
some fixes to behavior
diff --git a/flash/exception.py b/flash/exception.py
--- a/flash/exception.py
+++ b/flash/exception.py
@@ -1,6 +1,6 @@
class RedirectException(Exception):
- def __init__(self, redirect_uri, error=None, notice=None, *args, **kwargs):
+ def __init__(self, redirect_uri, notice=None, error=None, *args, **kwargs):
self.redirect_uri = redirect_uri
+ self.notice = notice
self.error = error
- self.notice = notice
Exception.__init__(self, *args, **kwargs)
diff --git a/flash/manager.py b/flash/manager.py
--- a/flash/manager.py
+++ b/flash/manager.py
@@ -8,7 +8,6 @@
self.messages = {'notices': [], 'errors': []}
self.next_messages = {'notices': [], 'errors': []}
- print 'cookies', request.COOKIES
if FLASH_COOKIE in request.COOKIES:
try:
self.messages = simplejson.loads(request.COOKIES[FLASH_COOKIE])
@@ -20,7 +19,6 @@
if self.next_messages['notices'] or self.next_messages['errors']:
data = simplejson.dumps(self.next_messages)
response.set_cookie(FLASH_COOKIE, data)#, max_age=FLASH_COOKIE_TIMEOUT)
- print 'setting cookie: %s' % data
else:
response.delete_cookie(FLASH_COOKIE)
diff --git a/flash/middleware.py b/flash/middleware.py
--- a/flash/middleware.py
+++ b/flash/middleware.py
@@ -10,10 +10,10 @@
def process_exception(self, request, exc):
if isinstance(exc, RedirectException):
if exc.error:
- request.error_next(exc.error)
+ request.flash.error_next(exc.error)
if exc.notice:
- request.notice_next(exc.notice)
- return HttpResponseRedirect(exception.redirect_uri)
+ request.flash.notice_next(exc.notice)
+ return HttpResponseRedirect(exc.redirect_uri)
def process_response(self, request, response):