无法在金字塔中的会话变量中保存数据

时间:2018-06-14 03:05:37

标签: python session pyramid

我正在尝试在会话变量中保存历史记录,但由于某种原因,session.save()不起作用,每次我都这样做,session = self.request.session,我没有得到更新会话

我的代码是

   def _update_page_history(self, _request):
    c = self.request.c
    request = self.request
    session = self.request.session

    title = c.title
    skip_history = True if ('error' in request.path_info
                            or 'auth' in request.path_info
                            or 'main' in request.path_info
                            or 'ajax' in request.path_info
                            or 'help/json' in request.path_info
                        ) else False

    if not skip_history:
        if request.query_string == '':
            session['page_history'].append({'title': title, 'path': request.path_info})
        else:
            if 'page_history' not in session:
                session['page_history'] = []
            session['page_history'].append({'title': title, 'path': request.path_info + '?' + request.query_string})

        session.save()
        session.changed()
        self.request.session = session

0 个答案:

没有答案