From 7ed60359e000a60dba4acaa920898695208723f3 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sat, 15 Jun 2013 01:35:24 +0200 Subject: [PATCH] [wiki/auth/theme] Un module pour choisir le themedu wiki en fonction du vhost --- wiki/auth/theme.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 wiki/auth/theme.py diff --git a/wiki/auth/theme.py b/wiki/auth/theme.py new file mode 100644 index 00000000..8bf4332e --- /dev/null +++ b/wiki/auth/theme.py @@ -0,0 +1,53 @@ +# -*- coding: iso-8859-1 -*- +""" + MoinMoin - CAS authentication + + Jasig CAS (see http://www.jasig.org/cas) authentication module. + + @copyright: 2012 MoinMoin:RichardLiao + @license: GNU GPL, see COPYING for details. +""" + +import sys +import os +import time, re +import urlparse +import urllib, urllib2 +from netaddr import IPNetwork, IPAddress + +from werkzeug import get_host + +from MoinMoin import log +logging = log.getLogger(__name__) + +from MoinMoin.auth import BaseAuth, ContinueLogin +from MoinMoin import user, wikiutil +from MoinMoin.theme import load_theme_fallback + + +class ThemeVhost(BaseAuth): + name = 'ThemeVhost' + login_inputs = [] + logout_possible = False + + def __init__(self, theme_vhost={}): + BaseAuth.__init__(self) + self.theme_vhost=theme_vhost; + + def request(self, request, user_obj, **kw): + host = get_host(request.environ) + if not user_obj: + theme_name = self.theme_vhost.get(host, request.user.theme_name) + else: + theme_name = self.theme_vhost.get(host, user_obj.theme_name) + + load_theme_fallback(request, theme_name) + return user_obj, True + + def login(self, request, user_obj, **kw): + return ContinueLogin(user_obj) + + + def logout(self, request, user_obj, **kw): + load_theme_fallback(request, request.cfg.theme_default) + return user_obj, True