[bitbake-devel] [PATCH 02/22] toaster: enable server-side sessions for all usages

Alex DAMIAN alexandru.damian at intel.com
Thu May 28 14:13:56 UTC 2015


From: Alexandru DAMIAN <alexandru.damian at intel.com>

In an effort to fix client-side session storage using
cookies, we enable server-side session support for all pages.

Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
---
 bin/toaster                         |  6 +++++-
 lib/toaster/toastergui/views.py     |  6 ++++--
 lib/toaster/toastermain/settings.py | 17 ++++++-----------
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/bin/toaster b/bin/toaster
index 18eba8e..93abcfa 100755
--- a/bin/toaster
+++ b/bin/toaster
@@ -53,7 +53,11 @@ function webserverStartAll()
     fi
 
     retval=0
-    python $BBBASEDIR/lib/toaster/manage.py syncdb || retval=1
+    if [ "$TOASTER_MANAGED" '==' '1' ]; then
+        python $BBBASEDIR/lib/toaster/manage.py syncdb || retval=1
+    else
+        python $BBBASEDIR/lib/toaster/manage.py syncdb --noinput || retval=1
+    fi
     python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=2
     if [ $retval -eq 1 ]; then
         echo "Failed db sync, stopping system start" 1>&2
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index 9217d8a..c16fc22 100755
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -266,8 +266,10 @@ def _get_queryset(model, queryset, filter_string, search_term, ordering_string,
 # if the value is given explicitly as a GET parameter it will be the first selected,
 # otherwise the cookie value will be used.
 def _get_parameters_values(request, default_count, default_order):
-    pagesize = request.GET.get('count', request.COOKIES.get('count', default_count))
-    orderby = request.GET.get('orderby', request.COOKIES.get('orderby', default_order))
+    from django.core.urlresolvers import resolve
+    current_url = resolve(request.path_info).url_name
+    pagesize = request.GET.get('count', request.session.get('%s_count' % current_url, default_count))
+    orderby = request.GET.get('orderby', request.session.get('%s_orderby' % current_url, default_order))
     return (pagesize, orderby)
 
 
diff --git a/lib/toaster/toastermain/settings.py b/lib/toaster/toastermain/settings.py
index 80f26e0..225138b 100644
--- a/lib/toaster/toastermain/settings.py
+++ b/lib/toaster/toastermain/settings.py
@@ -258,8 +258,13 @@ TEMPLATE_CONTEXT_PROCESSORS = ('django.contrib.auth.context_processors.auth',
  )
 
 INSTALLED_APPS = (
-    #'django.contrib.sites',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.messages',
+    'django.contrib.sessions',
+    'django.contrib.admin',
     'django.contrib.staticfiles',
+
     # Uncomment the next line to enable admin documentation:
     # 'django.contrib.admindocs',
     'django.contrib.humanize',
@@ -307,16 +312,6 @@ if os.environ.get('TOASTER_DEVEL', None) is not None:
 
 SOUTH_TESTS_MIGRATE = False
 
-# if we run in managed mode, we need user support
-if MANAGED:
-    INSTALLED_APPS = ('django.contrib.auth',
-    'django.contrib.contenttypes',
-    'django.contrib.messages',
-    'django.contrib.sessions',
-    # Uncomment the next line to enable the admin:
-    'django.contrib.admin',
-        ) + INSTALLED_APPS
-
 
 # We automatically detect and install applications here if
 # they have a 'models.py' or 'views.py' file
-- 
1.9.1




More information about the bitbake-devel mailing list