This patch also repairs bug with readonly_connection to mysql database. Signed-off-by: Jiří Župka <jzupka@xxxxxxxxxx> --- apache/conf/django-directives | 49 +++++++++++++++++++++++++++++-------- frontend/db/backends/afe/base.py | 11 ++++++++ frontend/frontend.wsgi | 32 ++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 frontend/frontend.wsgi diff --git a/apache/conf/django-directives b/apache/conf/django-directives index ce6c5c7..79914a0 100644 --- a/apache/conf/django-directives +++ b/apache/conf/django-directives @@ -13,6 +13,10 @@ RewriteEngine On RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/media -d RewriteRule /media/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/media/$1/$2 +# Django 1.4 does change location of the admin css files +RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/static/admin -d +RewriteRule /media/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/static/admin/$1/$2 + RewriteCond /usr/lib/python2.4/site-packages/django/contrib/admin/media -d RewriteRule /media/(css|img|js)(.*) /usr/lib/python2.4/site-packages/django/contrib/admin/media/$1/$2 @@ -25,14 +29,37 @@ RewriteRule /media/(css|img|js)(.*) /usr/lib/python2.6/site-packages/django/cont RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/media -d RewriteRule /media/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/media/$1/$2 -<Location ~ "/(afe|new_tko)/server"> - SetHandler python-program - PythonHandler django.core.handlers.modpython - SetEnv DJANGO_SETTINGS_MODULE frontend.settings - PythonDebug On - # Force our own site-packages to be loaded by mod_python prior - # to mod_python's system python site-packages directory. - # This way our code can depend on library versions other than - # those available as packages on various OS distributions. - PythonPath "['/usr/local/autotest/site-packages', '/usr/local/autotest', '/usr/lib/python2.7/site-packages/autotest', '/usr/lib/python2.6/site-packages/autotest', '/usr/lib/python2.5/site-packages/autotest', '/usr/lib/python2.4/site-packages/autotest'] + sys.path" -</Location> +# Django 1.4 does change location of the admin css files +RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin -d +RewriteRule /media/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin/$1/$2 + +#Old configuration for mod_python. + +#<Location ~ "/(afe|new_tko)/server"> +# SetHandler python-program +# PythonHandler django.core.handlers.modpython +# SetEnv DJANGO_SETTINGS_MODULE frontend.settings +# PythonDebug On +# # Force our own site-packages to be loaded by mod_python prior +# # to mod_python's system python site-packages directory. +# # This way our code can depend on library versions other than +# # those available as packages on various OS distributions. +# PythonPath "['/usr/local/autotest/site-packages', '/usr/local/autotest', '/usr/lib/python2.7/site-packages/autotest', '/usr/lib/python2.6/site-packages/autotest', '/usr/lib/python2.5/site-packages/autotest', '/usr/lib/python2.4/site-packages/autotest'] + sys.path" +#</Location> + + +#New configuration for mod_swgi + +RewriteRule ^/(afe|new_tko)/server(.*)$ /$1/server$2 [QSA,PT,L] + +WSGISocketPrefix run/wsgi +#Thread have to be only one because there could be problem with readonly_connection. +WSGIDaemonProcess apache processes=10 threads=1 +WSGIProcessGroup apache + +WSGIScriptAliasMatch /(afe|new_tko)/server.* /usr/local/autotest/frontend/frontend.wsgi + +<Directory /usr/local/autotest/frontend/> + Order allow,deny + Allow from all +</Directory> diff --git a/frontend/db/backends/afe/base.py b/frontend/db/backends/afe/base.py index 067abac..64114b8 100644 --- a/frontend/db/backends/afe/base.py +++ b/frontend/db/backends/afe/base.py @@ -20,3 +20,14 @@ class DatabaseWrapper(MySQLDatabaseWrapper): self.creation = MySQLCreation(self) self.ops = DatabaseOperations() self.introspection = MySQLIntrospection(self) + + def _valid_connection(self): + if self.connection is not None: + if self.connection.open: + try: + self.connection.ping() + return True + except DatabaseError: + self.connection.close() + self.connection = None + return False diff --git a/frontend/frontend.wsgi b/frontend/frontend.wsgi new file mode 100644 index 0000000..ff1e54b --- /dev/null +++ b/frontend/frontend.wsgi @@ -0,0 +1,32 @@ +import os, sys + +try: + import autotest.common +except ImportError: + frontend_dir = os.path.dirname(sys.modules[__name__].__file__) + sys.path.insert(0, frontend_dir) + import common + sys.path.pop(0) + +path_list = ['/usr/local/autotest/site-packages', '/usr/local/autotest', + '/usr/lib/python2.7/site-packages/autotest', + '/usr/lib/python2.6/site-packages/autotest', + '/usr/lib/python2.5/site-packages/autotest', + '/usr/lib/python2.4/site-packages/autotest'] + +for p in path_list: + if os.path.isdir(p): + sys.path.append(p) + +os.environ['DJANGO_SETTINGS_MODULE'] = 'autotest.frontend.settings' +#os.environ['DJANGO_USE_POST_REWRITE'] = "aaa" + + +import django.core.handlers.wsgi + +_application = django.core.handlers.wsgi.WSGIHandler() + +def application(environ, start_response): + environ['DJANGO_USE_POST_REWRITE'] = "yes" + environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO'] + return _application(environ, start_response) -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html