I've been trying to integrate a DJANGO-REST WS into apache using MOD_WSGI, 
but after some long hours of trying to apply all debugging techniques and 
different wsgi scripts, I would appreciate some help.

Server version: Apache/2.2.22 (Ubuntu)
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
MOD_WSGI Version: 3.3

Currently my WSGI file is the following:

"""
WSGI config for zighome_rest project.

It exposes the WSGI callable as a module-level variable named 
``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""

import os, sys
sys.path.append('/usr/local/ZigHomeWS')
sys.path.append('/usr/local/ZigHomeWS/zighome_rest')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zighome_rest.settings")

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

and my virtual host is configured as below:

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName my.server.name

DocumentRoot /usr/local/DummyApp

        WSGIDaemonProcess ZigHomeWS 
python-path=/usr/local/ZigHomeWS/zighome_rest:/usr/lib/python2.7:/usr/local/lib/python2.7/site-packages/django
        WSGIProcessGroup ZigHomeWS
        WSGIApplicationGroup %{GLOBAL}

        WSGIScriptAlias /ZigHomeWS 
/usr/local/ZigHomeWS/zighome_rest/zighome_rest/WSGI/django.wsgi
        WSGIPassAuthorization On

        <Directory /usr/local/ZigHomeWS/zighome_rest>
            <Files wsgi.py>
                Order deny,allow
                Allow from all
            </Files>
        </Directory>
        
        <Directory /usr/local/DummyApp>
            Order deny,allow
            Allow from all
        </Directory>
        
        ErrorLog /var/log/apache2/error_ZigHomeWS.log

        # Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel info
</VirtualHost>

As soon as I call one of the services, with curl, I get the following error 
logged:

[Sat Sep 27 19:15:28 2014] [info] mod_wsgi (pid=13351): Adding 
'/usr/local/ZigHomeWS/zighome_rest' to path.
[Sat Sep 27 19:15:28 2014] [info] mod_wsgi (pid=13351): Adding 
'/usr/lib/python2.7' to path.
[Sat Sep 27 19:15:28 2014] [info] mod_wsgi (pid=13351): Adding 
'/usr/local/lib/python2.7/site-packages/django' to path.
[Sat Sep 27 19:15:32 2014] [info] [client 46.189.221.224] mod_wsgi 
(pid=13351, process='ZigHomeWS', application=''): Loading WSGI script 
'/usr/local/ZigHomeWS/zighome_rest/zighome_rest/WSGI/django.wsgi'.
[Sat Sep 27 18:15:33 2014] [error] No handlers could be found for logger 
"django.request"
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224] mod_wsgi 
(pid=13351): Exception occurred processing WSGI script 
'/usr/local/ZigHomeWS/zighome_rest/zighome_rest/WSGI/django.wsgi'.
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224] Traceback (most 
recent call last):
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 
187, in __call__
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     response = 
self.get_response(request)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 
199, in get_response
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     response = 
self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 
236, in handle_uncaught_exception
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
debug.technical_500_response(request, *exc_info)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 91, in 
technical_500_response
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     html = 
reporter.get_traceback_html()
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 350, 
in get_traceback_html
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
t.render(c)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 148, 
in render
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
self._render(context)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 142, 
in _render
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
self.nodelist.render(context)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 844, 
in render
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     bit = 
self.render_node(node, context)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 80, 
in render_node
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
node.render(context)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 90, 
in render
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     output = 
self.filter_expression.resolve(context)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 624, 
in resolve
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     new_obj = 
func(obj, *arg_vals)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", 
line 769, in date
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
format(value, arg)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 
343, in format
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
df.format(format_string)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 
35, in format
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     
pieces.append(force_text(getattr(self, piece)()))
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 
268, in r
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
self.format('D, j M Y H:i:s O')
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 
35, in format
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     
pieces.append(force_text(getattr(self, piece)()))
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 85, 
in force_text
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     s = 
six.text_type(s)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 
144, in __text_cast
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
func(*self.__args, **self.__kw)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", 
line 83, in ugettext
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
_trans.ugettext(message)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
 
line 325, in ugettext
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     return 
do_translate(message, 'ugettext')
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
 
line 306, in do_translate
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     _default = 
translation(settings.LANGUAGE_CODE)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
 
line 209, in translation
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     
default_translation = _fetch(settings.LANGUAGE_CODE)
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]   File 
"/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
 
line 189, in _fetch
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224]     "The 
translation infrastructure cannot be initialized before the "
[Sat Sep 27 18:15:33 2014] [error] [client 46.189.221.224] 
AppRegistryNotReady: The translation infrastructure cannot be initialized 
before the apps registry is ready. Check that you don't make non-lazy 
gettext calls at import time.

I must confess that adding "/usr/local/lib/python2.7/site-packages/django" 
was just a measure of desperation, which end-up by resulting on nothing.

One thing I should probably mention, although it shouldn't make any 
difference of the solution, is that the core system is actually a C++ 
system which I wrapped up with SWIG.

Needless to say, it's working on the Django-REST development environment.

Last but not least, if in the WSGI script file I change these two lines:

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

by these:

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

It will crash instead of providing the stack trace in the log file:

[Sat Sep 27 19:44:10 2014] [error] [client 46.189.221.224] Premature end of 
script headers: django.wsgi

I end up applying some debugging the recommended debugging techniques but 
unfortunately it wasn't very helpful, since the stack-trace of gdb just 
gave me:

(gdb) cont
Continuing.
[New Thread 0x7fc6d4de9700 (LWP 9312)]
[New Thread 0x7fc6d45e8700 (LWP 9313)]
[Thread 0x7fc6dde3a700 (LWP 9242) exited]
[Thread 0x7fc6d45e8700 (LWP 9313) exited]
[Thread 0x7fc6d4de9700 (LWP 9312) exited]
[Thread 0x7fc6dd639700 (LWP 9245) exited]
[Thread 0x7fc6e364a740 (LWP 9216) exited]
[Inferior 1 (process 9216) exited with code 01]


I hope you can provide me with some help

Thank you


-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to