[ckan-changes] [okfn/ckan] 6add60: [release-v1.6.1][noticket]: Allow session to be us...

GitHub noreply at github.com
Tue Apr 17 15:15:48 UTC 2012


  Branch: refs/heads/release-v1.6.1
  Home:   https://github.com/okfn/ckan
  Commit: 6add60d33b653d1fc7f2a6863d2e4b045c4792f8
      https://github.com/okfn/ckan/commit/6add60d33b653d1fc7f2a6863d2e4b045c4792f8
  Author: David Read <david.read at okfn.org>
  Date:   2012-04-17 (Tue, 17 Apr 2012)

  Changed paths:
    M ckan/lib/base.py

  Log Message:
  -----------
  [release-v1.6.1][noticket]: Allow session to be used by DGU (ckanext-os).


diff --git a/ckan/lib/base.py b/ckan/lib/base.py
index b10c980..0dfe78e 100644
--- a/ckan/lib/base.py
+++ b/ckan/lib/base.py
@@ -193,12 +193,20 @@ def __call__(self, environ, start_response):
                 if cookie.startswith('ckan') and cookie not in ['ckan']:
                     response.delete_cookie(cookie)
                 # Remove the ckan session cookie if not used e.g. logged out
-                elif cookie == 'ckan' and not c.user and not h.are_there_flash_messages():
-                    if session.id:
-                        if not session.get('lang'):
-                            session.delete()
-                    else:
-                        response.delete_cookie(cookie)
+                elif cookie == 'ckan' and not c.user:
+                    # Check session for valid data (including flash messages)
+                    # (DGU also uses session for a shopping basket-type behaviour)
+                    is_valid_cookie_data = False
+                    for key, value in session.items():
+                        if not key.startswith('_') and value:
+                            is_valid_cookie_data = True
+                            break
+                    if not is_valid_cookie_data:
+                        if session.id:
+                            if not session.get('lang'):
+                                session.delete()
+                        else:
+                            response.delete_cookie(cookie)
                 # Remove auth_tkt repoze.who cookie if user not logged in.
                 elif cookie == 'auth_tkt' and not session.id:
                     response.delete_cookie(cookie)


================================================================



More information about the ckan-changes mailing list