Refactor progress bars somewhat to allow file-based sessions
hoping this solves issue of Apache restart at end of upgrade
This commit is contained in:
parent
f203f2c377
commit
f46e20c119
8 changed files with 48 additions and 37 deletions
|
@ -1,4 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
|
@ -26,15 +26,21 @@ Progress Indicator
|
|||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import os
|
||||
|
||||
from beaker.session import Session
|
||||
|
||||
|
||||
def get_progress_session(request, key):
|
||||
def get_progress_session(request, key, **kwargs):
|
||||
"""
|
||||
Create/get a Beaker session object, to be used for progress.
|
||||
"""
|
||||
id = '{0}.progress.{1}'.format(request.session.id, key)
|
||||
return Session(request, id, use_cookies=False)
|
||||
id = '{}.progress.{}'.format(request.session.id, key)
|
||||
kwargs['use_cookies'] = False
|
||||
if kwargs.get('type') == 'file':
|
||||
kwargs['data_dir'] = os.path.join(request.rattail_config.appdir(), 'sessions')
|
||||
session = Session(request, id, **kwargs)
|
||||
return session
|
||||
|
||||
|
||||
class SessionProgress(object):
|
||||
|
@ -46,8 +52,9 @@ class SessionProgress(object):
|
|||
for display to the user.
|
||||
"""
|
||||
|
||||
def __init__(self, request, key):
|
||||
self.session = get_progress_session(request, key)
|
||||
def __init__(self, request, key, session_type=None):
|
||||
self.key = key
|
||||
self.session = get_progress_session(request, key, type=session_type)
|
||||
self.canceled = False
|
||||
self.clear()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue