fixed language selection bug

added unittest to CryptoBoxPlugin
This commit is contained in:
lars 2006-10-26 12:28:50 +00:00
parent 10c52fb51c
commit 0d41663ec3
3 changed files with 24 additions and 6 deletions

View file

@ -118,3 +118,18 @@ class CryptoBoxPlugin:
except KeyError, TypeError:
return self.rank
def getTestClass(self):
import imp
pl_file = os.path.join(self.pluginDir, "unittests.py")
if os.access(pl_file, os.R_OK) and os.path.isfile(pl_file):
try:
return getattr(imp.load_source("unittests_%s" % self.getName(), pl_file), "unittests")
except AttributeError:
pass
try:
self.cbox.log.info("could not load unittests for plugin: %s" % self.getName())
except AttributeError:
pass
return None

View file

@ -89,7 +89,7 @@ class WebInterfaceSites:
else:
self.cbox.log.info("unknown user: %s" % str(user))
## wrong credentials: return "access denied"
cherrypy.response.headers["WWW-Authenticate"] = '''Basic realm="Test-Arena"'''
cherrypy.response.headers["WWW-Authenticate"] = '''Basic realm="CryptoBox"'''
cherrypy.response.status = 401
return self.__render("access_denied")
return _inner_wrapper
@ -242,10 +242,13 @@ class WebInterfaceSites:
## no language specified: check browser language
if not guess:
guess = self.__getPreferredBrowserLanguage(availLangs)
if not guess or \
not guess in availLangs or \
re.search(u'\W', guess):
self.cbox.log.info("invalid language choosen: %s" % guess)
## no preferred language or invalid language?
if not guess \
or not guess in availLangs \
or re.search(u'\W', guess):
## warn only for invalid languages
if not guess is None:
self.cbox.log.info("invalid language choosen: %s" % guess)
guess = self.prefs["WebSettings"]["Language"]
## maybe the language is still not valid
if not guess in availLangs:

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python2.4
import unittest
import CryptoBoxTools