Difference between revisions of "Python Django"

From Tmplab
(New page: = Debugging django = passenger_wsgi.py {{{ #!/usr/bin/python import sys, os f=open("/tmp/djangodebug", "w+") f.flush() sys.stderr = f try: import sys, os sys.path.append(os.get...)
 
(Debugging django)
Line 1: Line 1:
 
 
= Debugging django =
 
= Debugging django =
  
 
passenger_wsgi.py
 
passenger_wsgi.py
  
{{{
+
<PRE>
 
#!/usr/bin/python
 
#!/usr/bin/python
 
import sys, os
 
import sys, os
Line 24: Line 23:
 
     f.write('------------------------------')
 
     f.write('------------------------------')
 
     f.close()
 
     f.close()
}}}
+
</PRE>

Revision as of 23:13, 4 November 2010

Debugging django

passenger_wsgi.py

#!/usr/bin/python
import sys, os
f=open("/tmp/djangodebug", "w+")
f.flush()
sys.stderr = f

try:
    import sys, os
    sys.path.append(os.getcwd())
    os.environ['DJANGO_SETTINGS_MODULE'] = "XXX"
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
except:
    f.flush()
    print "Unexpected error:", sys.exc_info()[0]
    f.write('------------------------------')
    f.write(sys.exc_info()[0])
    f.write('------------------------------')
    f.close()