Servicios > English support (For non-Spaniard users)

Problem with setting up django app

<< < (2/3) > >>

shakaran:
I finally solve the problem, it seems a bug on psycopg 2.4.4 on the file psycopg/lobject_int.c:


--- Citar ---.psycopg/lobject_int.c:478:    retvalue = lo_truncate(self->conn->pgconn, self->fd, len);
--- Fin de la cita ---

http://www.postgresql.org/docs/9.0/static/lo-interfaces.html#LO-TRUNCATE

I install the development version that fix the bug, so now it is working:


--- Citar ---# python -c "import psycopg2; print psycopg2.__version__"
2.4.5.dev0 (dt dec pq3 ext)

--- Fin de la cita ---

Try now with psycopg2 and manage.py if solves your problem and post here again your result.

The error that the trace shows:


--- Código: ---File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/uti
ls/simplejson/__init__.py", line 111, in <module>
    import simplejson
  File "/usr/local/lib/python2.7/site-packages/simplejson-2.3.0-py2.7-linux-x86_
64.egg/simplejson/__init__.py", line 111, in <module>
    from decoder import JSONDecoder, JSONDecodeError
MemoryError
--- Fin del código ---

Seems more a bug (memory leak) on Django or simplejson module reading your settings.py. The server1 has 8 GB of Ram and normally used 2-4 GB, so it is pretty weird that you receive a MemoryError exception.

Try again and keep me aware of you results. Soon Django 1.4 would be released so maybe we can update soon for fix this.

Lwoo:
OK, as I mentioned previously the syncdb problem is gone and the database seems to work fine.

However, I can't get the project running. This is what I get in error log:


--- Código: ---[Wed Mar 14 00:42:24 2012] [error] [client x.x.x.x]   File "/home/monfloo/public_html/monfloo-landing/django.wsgi", line 9, in <module>
[Wed Mar 14 00:42:24 2012] [error] [client x.x.x.x] mod_wsgi (pid=32211): Exception occurred processing WSGI script '/home/monfloo/public_html/monfloo-landing/django.wsgi'.
[Wed Mar 14 00:42:24 2012] [error] [client x.x.x.x] mod_wsgi (pid=32211): Target WSGI script '/home/monfloo/public_html/monfloo-landing/django.wsgi' cannot be loaded as Python module.
[Wed Mar 14 00:42:24 2012] [error] [client x.x.x.x]   File "/home/monfloo/public_html/monfloo-landing/django.wsgi", line 9, in <module>
[Wed Mar 14 00:42:24 2012] [error] [client x.x.x.x] mod_wsgi (pid=32211): Exception occurred processing WSGI script '/home/monfloo/public_html/monfloo-landing/django.wsgi'.
[Wed Mar 14 00:42:24 2012] [error] [client x.x.x.x] mod_wsgi (pid=32211): Target WSGI script '/home/monfloo/public_html/monfloo-landing/django.wsgi' cannot be loaded as Python module.

--- Fin del código ---

My django.wsgi:


--- Código: ---#!/usr/local/bin python
# -*- coding: utf-8 -*-

import os, sys, traceback
import django.core.handlers.wsgi
import psycopg2

filename = 'error_log.txt'
f = open(filename, 'w')

try:
    sys.path.append('/home/monfloo/monfloo-lp/monfloo_lp')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'monfloo_lp.settings'
    os.environ['PYTHON_EGG_CACHE'] = '/home/monfloo/tmp/trac-eggs'

    application = django.core.handlers.wsgi.WSGIHandler()
    f.write('Ok')
except:
    traceback.print_exc(file=f)
--- Fin del código ---

.htaccess:


--- Código: ---Options ExecCGI
Options +FollowSymLinks
SetHandler wsgi-script

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(django.wsgi)
RewriteRule ^(.*)$ django.wsgi/$1 [L]

--- Fin del código ---

I checked whether wsgi is working by testing the solution found on http://groups.google.com/group/django-users/browse_thread/thread/45bf45ec14bab5dd/b7bfcc750ff9de14 as well as yours, from http://quijost.com/foro/desarrollo-web/ejemplo-de-prueba-index-py-para-django-y-mysql-con-mod_wgsi/ - both work as expected.

Any idea what I have done wrong or what is missing?

shakaran:
Hi again Lwoo,

Sorry for the delay.

This appears on root error log:


--- Código: ---[Wed Mar 14 00:57:15 2012] [error] [client XX.XX.XX.XX] mod_wsgi (pid=12662): Target WSGI script '/home/monfloo/public_html/monfloo-landing/django.wsgi' cannot be loaded as Python module.
[Wed Mar 14 00:57:15 2012] [error] [client XX.XX.XX.XX] mod_wsgi (pid=12662): Exception occurred processing WSGI script '/home/monfloo/public_html/monfloo-landing/django.wsgi'.
[Wed Mar 14 00:57:15 2012] [error] [client XX.XX.XX.XX] Traceback (most recent call last):
[Wed Mar 14 00:57:15 2012] [error] [client XX.XX.XX.XX]   File "/home/monfloo/public_html/monfloo-landing/django.wsgi", line 9, in <module>
[Wed Mar 14 00:57:15 2012] [error] [client XX.XX.XX.XX]     f = open(filename, 'w')
[Wed Mar 14 00:57:15 2012] [error] [client XX.XX.XX.XX] IOError: [Errno 13] Permission denied: 'error_log.txt'
[Wed Mar 14 00:57:15 2012] [warn] [client XX.XX.XX.XX] mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
--- Fin del código ---

Seems that you need set previously a the write permissions on error_log.txt and also complains about "Options +Includes"

Note too that sys.path.append('/home/monfloo/monfloo-lp/monfloo_lp') is wrong. You should put with public_html sys.path.append('/home/monfloo/public_html/monfloo-lp/')

Lwoo:
I had CHMODed error_log.txt to 666, after your reply I changed it even to 777, but it's still empty.  :-\ Switched back to 666.

Also, I modified my .htaccess as follows:


--- Código: ---Options ExecCGI
Options +FollowSymLinks
Options +Includes
SetHandler wsgi-script

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(django.wsgi)
RewriteRule ^(.*)$ django.wsgi/$1 [L]

--- Fin del código ---

Moved the project from /home/monfloo/monfloo_lp to /home/monfloo/public_html/monfloo_lp and edited django.wsgi accordingly:


--- Código: ---#!/usr/local/bin python
# -*- coding: utf-8 -*-

import os, sys, traceback
import django.core.handlers.wsgi
import psycopg2

filename = 'error_log.txt'
f = open(filename, 'w')

try:
    sys.path.append('/home/monfloo/public_html/monfloo-lp')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'monfloo_lp.settings'
    os.environ['PYTHON_EGG_CACHE'] = '/home/monfloo/tmp/trac-eggs'

    application = django.core.handlers.wsgi.WSGIHandler()
    f.write('Ok')
except:
    traceback.print_exc(file=f)
--- Fin del código ---

However, still no success - it keeps on complaining that "Target WSGI script '/home/monfloo/public_html/monfloo-landing/django.wsgi' cannot be loaded as Python module.", just as if nothing has been modified. :(

shakaran:
I will check this for try to find a solution, but it could be that a owner file permissions. I mean user/group options as running as apache (nobody/nobody). And Django runs then as Apache application too handled by ws-script

But write a file should could make easily, because Django write files without problems but no running as apache user (nobody/nobody).

You could try use logging module or even more advanced solutions for fetch the exceptions:

http://www.davidcramer.net/code/502/debugging-django-errors.html
http://lucumr.pocoo.org/2007/5/21/getting-started-with-wsgi

Navegación

[0] Índice de Mensajes

[#] Página Siguiente

[*] Página Anterior

Ir a la versión completa