From cbd1d29bc4796410223897a3269ba470943bf16f Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Tue, 21 Jul 2015 15:38:12 +0200 Subject: making gen_url get args order predictable so cache generation works --- pyaggr3g470r/views/views.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py index 2aeaaa20..0071f887 100644 --- a/pyaggr3g470r/views/views.py +++ b/pyaggr3g470r/views/views.py @@ -32,6 +32,8 @@ import random import hashlib import logging import datetime +from collections import OrderedDict + from bootstrap import application as app, db from flask import render_template, request, flash, session, \ url_for, redirect, g, current_app, make_response, Response @@ -268,15 +270,22 @@ def render_home(filters=None, head_titles=None, def gen_url(filter_=filter_, sort_=sort_, limit=limit, feed_id=feed_id, **kwargs): + o_kwargs = OrderedDict() + for key in sorted(kwargs): + o_kwargs[key] = kwargs[key] if page_to_render == 'search': - kwargs['query'] = request.args.get('query', '') - kwargs['search_title'] = request.args.get('search_title', 'off') - kwargs['search_content'] = request.args.get( + o_kwargs['query'] = request.args.get('query', '') + o_kwargs['search_title'] = request.args.get('search_title', 'off') + o_kwargs['search_content'] = request.args.get( 'search_content', 'off') - if kwargs['search_title'] == kwargs['search_content'] == 'off': - kwargs['search_title'] = 'on' - return url_for(page_to_render, filter_=filter_, sort_=sort_, - limit=limit, feed_id=feed_id, **kwargs) + # if nor title and content are selected, selecting title + if o_kwargs['search_title'] == o_kwargs['search_content'] == 'off': + o_kwargs['search_title'] = 'on' + o_kwargs['filter_'] = filter_ + o_kwargs['sort_'] = sort_ + o_kwargs['limit'] = limit + o_kwargs['feed_id'] = feed_id + return url_for(page_to_render, **o_kwargs) articles = list(articles) if (page_to_render == 'home' and feed_id or page_to_render == 'search') \ -- cgit