From c7b8d77da0c1a9a863b0ccda96386acff68e1a78 Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Wed, 19 Dec 2012 12:25:19 +0000 Subject: [PATCH] Made change_theme() more stable (so 404 pages render properly) --- i2p2www/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/i2p2www/__init__.py b/i2p2www/__init__.py index ba4d228b1..bda0cc090 100644 --- a/i2p2www/__init__.py +++ b/i2p2www/__init__.py @@ -243,9 +243,14 @@ def utility_processor(): # Change the theme of the current page def change_theme(theme): - args = request.view_args.copy() + args = {} + if request.view_args: + args = request.view_args.copy() args['theme'] = theme - return url_for(request.endpoint, **args) + if request.endpoint: + return url_for(request.endpoint, **args) + # Probably a 404 error page + return url_for('main_index', **args) return dict(i2pconv=convert_url_to_clearnet, url_for_other_page=url_for_other_page, -- GitLab