mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
Fixed a bug with encodings when using extended chars (such as á, ...). Set default encoding at "wsgi.py" to UTF-8 and added a custom "sitecustomize.py" so, in case we run server from command line (with PYTHONPATH at least pointing to "."), correctly sets the encoding to UTF-8
This commit is contained in:
parent
abd4246b40
commit
a4c1f6af8f
@ -13,6 +13,10 @@ middleware here, or combine a Django application with an application of another
|
||||
framework.
|
||||
|
||||
"""
|
||||
import sys
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('UTF-8')
|
||||
|
||||
import os
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
|
||||
|
3
server/src/sitecustomize.py
Normal file
3
server/src/sitecustomize.py
Normal file
@ -0,0 +1,3 @@
|
||||
import sys
|
||||
|
||||
sys.setdefaultencoding('UTF-8')
|
@ -49,6 +49,8 @@ class Cache(object):
|
||||
|
||||
|
||||
def __getKey(self, key):
|
||||
import os
|
||||
logger.debug(os.environ)
|
||||
h = hashlib.md5()
|
||||
h.update(self._owner + key)
|
||||
return h.hexdigest()
|
||||
|
@ -47,10 +47,11 @@ class Config:
|
||||
'''
|
||||
|
||||
class _Value:
|
||||
def __init__(self, section, key, default = '', crypt = False):
|
||||
def __init__(self, section, key, default = '', crypt = False, longText = False):
|
||||
self._section = section
|
||||
self._key = key
|
||||
self._crypt = crypt
|
||||
self._longText = longText
|
||||
if crypt is False:
|
||||
self._default = default
|
||||
else:
|
||||
@ -66,12 +67,11 @@ class Config:
|
||||
self._crypt = [self._crypt, True][readed.crypt] # True has "higher" precedende than False
|
||||
except Exception:
|
||||
# Not found
|
||||
if self._default != '':
|
||||
if self._crypt:
|
||||
self.set( CryptoManager.manager().decrypt(self._default) )
|
||||
else:
|
||||
self.set(self._default)
|
||||
self._data = self._default
|
||||
if self._default != '' and self._crypt:
|
||||
self.set( CryptoManager.manager().decrypt(self._default) )
|
||||
elif not self._crypt:
|
||||
self.set(self._default)
|
||||
self._data = self._default
|
||||
if self._crypt is True:
|
||||
return CryptoManager.manager().decrypt(self._data)
|
||||
else:
|
||||
@ -96,6 +96,9 @@ class Config:
|
||||
|
||||
def isCrypted(self):
|
||||
return self._crypt
|
||||
|
||||
def isLongText(self):
|
||||
return self._longText
|
||||
|
||||
def set(self, value):
|
||||
if self._crypt is True:
|
||||
@ -124,6 +127,9 @@ class Config:
|
||||
def valueCrypt(self, key, default = ''):
|
||||
return Config._Value(self, key, default, True)
|
||||
|
||||
def valueLong(self, key, default = ''):
|
||||
return Config._Value(self, key, default, False, True)
|
||||
|
||||
def name(self):
|
||||
return self._sectionName
|
||||
|
||||
@ -208,6 +214,8 @@ class GlobalConfig:
|
||||
# Max time needed to get a service "fully functional" before it's considered "failed" and removed
|
||||
# The time is in seconds
|
||||
MAX_INITIALIZING_TIME = Config.section(GLOBAL_SECTION).value('maxInitTime', '3600')
|
||||
# Custom HTML for login page
|
||||
CUSTOM_HTML_LOGIN = Config.section(GLOBAL_SECTION).valueLong('customHtmlLogin', '')
|
||||
|
||||
|
||||
initDone = False
|
||||
@ -238,7 +246,8 @@ class GlobalConfig:
|
||||
GlobalConfig.AUTORUN_SERVICE.get()
|
||||
GlobalConfig.REDIRECT_TO_HTTPS.get()
|
||||
GlobalConfig.MAX_INITIALIZING_TIME.get()
|
||||
except Exception, e:
|
||||
GlobalConfig.CUSTOM_HTML_LOGIN.get()
|
||||
except:
|
||||
logger.debug('Config table do not exists!!!, maybe we are installing? :-)')
|
||||
|
||||
# Context processor
|
||||
|
Loading…
Reference in New Issue
Block a user