Module: check_mk
Branch: master
Commit: c1f6dbf27dfef09e21a9e8f0b77d0125d5dd3f88
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c1f6dbf27dfef0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Aug 1 14:03:09 2016 +0200
3730 FIX Improved GUI performance in case of different languages used by users
In case there are users using different languages in the GUI, the interface could load
slower since the GUI needs to re-initialize different code parts (multisite plugins) each
time a user with a different language accesses the GUI.
In technical detail: Each apache process has one Python interpreter which serves the
Check_MK GUI. Once a request arrives, the whole GUI code is loaded in the language
of the user. This loaded GUI is cached until a user with another language requests
a page from this apache process. The cache needs to be renewed then. This takes a
lot longer than simply using the cache.
We have now improved the situation by routing the requests to language dependent,
so called, sub interpreters. Each apache process can now have a default language
(english) interpreter and an e.g. German language sub interpreter which each have
caches on their own and thus never need to reinitialze their cached GUI now.
---
.werks/3730 | 22 ++++++++++++++++++++++
ChangeLog | 1 +
web/htdocs/i18n.py | 16 ++++++++++++++++
web/htdocs/login.py | 2 ++
web/htdocs/wato.py | 1 +
5 files changed, 42 insertions(+)
diff --git a/.werks/3730 b/.werks/3730
new file mode 100644
index 0000000..c9dd425
--- /dev/null
+++ b/.werks/3730
@@ -0,0 +1,22 @@
+Title: Improved GUI performance in case of different languages used by users
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.4.0i1
+Date: 1470052655
+Class: fix
+
+In case there are users using different languages in the GUI, the interface could load
+slower since the GUI needs to re-initialize different code parts (multisite plugins)
each
+time a user with a different language accesses the GUI.
+
+In technical detail: Each apache process has one Python interpreter which serves the
+Check_MK GUI. Once a request arrives, the whole GUI code is loaded in the language
+of the user. This loaded GUI is cached until a user with another language requests
+a page from this apache process. The cache needs to be renewed then. This takes a
+lot longer than simply using the cache.
+
+We have now improved the situation by routing the requests to language dependent,
+so called, sub interpreters. Each apache process can now have a default language
+(english) interpreter and an e.g. German language sub interpreter which each have
+caches on their own and thus never need to reinitialze their cached GUI now.
diff --git a/ChangeLog b/ChangeLog
index a7f4336..e7b428f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -412,6 +412,7 @@
* 3723 FIX: Mobile GUI: Don't mix classic and mobile GUI when choosing classic on
mobile device
* 3645 FIX: Fixed filesystem growth/shrinkage graph by splitting it up into 2
graphs.
* 3729 FIX: Disabling password field completion for most forms, even in current
Chrome
+ * 3730 FIX: Improved GUI performance in case of different languages used by users...
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node
selection...
diff --git a/web/htdocs/i18n.py b/web/htdocs/i18n.py
index e1a3c6e..6989966 100644
--- a/web/htdocs/i18n.py
+++ b/web/htdocs/i18n.py
@@ -115,6 +115,8 @@ def unlocalize():
def localize(lang, **kwargs):
+ set_language_cookie(lang)
+
if lang:
# FIXME: Clean this up. Make the other code access the current language through
a
# function of this module.
@@ -133,6 +135,20 @@ def initialize():
__builtin__._u = _u
unlocalize()
+
+def del_language_cookie():
+ html.del_cookie("language")
+
+
+def set_language_cookie(lang):
+ cookie_lang = html.cookie("language", None)
+ if cookie_lang != lang:
+ if lang != None:
+ html.set_cookie("language", lang)
+ else:
+ del_language_cookie()
+
+
#.
# .--User i18n-----------------------------------------------------------.
# | _ _ _ _ ___ |
diff --git a/web/htdocs/login.py b/web/htdocs/login.py
index 43eb7bd..cefa910 100644
--- a/web/htdocs/login.py
+++ b/web/htdocs/login.py
@@ -29,6 +29,7 @@ from lib import *
from html_mod_python import FinalizeRequest
import os, time
import traceback
+import i18n
try:
from hashlib import md5
@@ -112,6 +113,7 @@ def invalidate_auth_session():
userdb.invalidate_session(config.user_id)
del_auth_cookie()
+ i18n.del_language_cookie()
def renew_auth_session(username):
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index fdc1949..888bcc0 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -13892,6 +13892,7 @@ def page_user_profile(change_pw=False):
# Set custom language
users[config.user_id]['language'] = language
config.user['language'] = language
+ i18n.set_language_cookie(language)
else:
# Remove the customized language