WSGI requires that you have a callable called `application` defined directly
in your *.wsgi file...
In your code, application is just a method of your Handler class, so it's
not going to work at all. Consider using one of these three patterns...
# Pattern 1
def application(environ, start_response):
start_resposne(...)
return [content]
# Pattern 2
class MyApplication:
def __init__(self):
...
def __call__(self, environ, start_response):
start_response(...)
return [content]
application = MyApplication()
# Pattern 3
class application:
def __new__(cls, environ, start_response)
self = object.__new__(cls) # is this right?
content = self.DoSomething(environ)
start_response(...)
return [content]
On Thu, Oct 21, 2010 at 2:53 PM, nitin chandra <[email protected]>wrote:
> Ok ... i think here is the culprit ... which has been troubling me ...
> "application" not found in script.... gives an internal server error
> '500'
>
> [Thu Oct 21 23:18:43 2010] [notice] Apache/2.2.15 (Unix)
> mod_ssl/2.2.15 OpenSSL/0.9.8k DAV/2 mod_wsgi/3.2 Python/2.6.5
> configured -- resuming normal operations
> [Thu Oct 21 23:18:47 2010] [error] [client 192.168.1.9] mod_wsgi
> (pid=1794): Target WSGI script '/home/dev/wsgi-scripts/index.py' does
> not contain WSGI application 'application'.
> [Thu Oct 21 23:18:47 2010] [error] [client 192.168.1.9] Target WSGI
> script not found or unable to stat: /home/dev/wsgi-scripts/favicon.ico
> [Thu Oct 21 23:20:13 2010] [error] [client 192.168.1.9] Target WSGI
> script not found or unable to stat: /home/dev/wsgi-scripts/favicon.ico
> [Thu Oct 21 23:20:19 2010] [error] [client 192.168.1.9] mod_wsgi
> (pid=1796): Target WSGI script '/home/dev/wsgi-scripts/index.py' does
> not contain WSGI application 'application'.
> [Thu Oct 21 23:28:20 2010] [error] [client 192.168.1.9] Target WSGI
> script not found or unable to stat: /home/dev/wsgi-scripts/favicon.ico
> [Thu Oct 21 23:34:15 2010] [error] [client 192.168.1.9] Target WSGI
> script not found or unable to stat: /home/dev/wsgi-scripts/favicon.ico
> [Thu Oct 21 23:34:16 2010] [error] [client 192.168.1.9] mod_wsgi
> (pid=1797): Target WSGI script '/home/dev/wsgi-scripts/index.py' does
> not contain WSGI application 'application'.
> [Thu Oct 21 23:34:19 2010] [error] [client 192.168.1.9] mod_wsgi
> (pid=1792): Target WSGI script '/home/dev/wsgi-scripts/index.py' does
> not contain WSGI application 'application'.
> [Thu Oct 21 23:34:28 2010] [error] Exception KeyError:
> KeyError(140078841251616,) in <module 'threading' from
> '/usr/lib/python2.6/threading.pyc'> ignored
> [Thu Oct 21 23:34:28 2010] [error] [client 192.168.1.9] mod_wsgi
> (pid=1793): Target WSGI script '/home/dev/wsgi-scripts/index.py' does
> not contain WSGI application 'application'.
> [Thu Oct 21 23:40:19 2010] [error] [client 192.168.1.9] Target WSGI
> script not found or unable to stat: /home/dev/wsgi-scripts/favicon.ico
> [Thu Oct 21 23:40:20 2010] [error] [client 192.168.1.9] mod_wsgi
> (pid=1793): Target WSGI script '/home/dev/wsgi-scripts/index.py' does
> not contain WSGI application 'application'.
> [Thu Oct 21 23:40:21 2010] [error] [client 192.168.1.9] mod_wsgi
> (pid=1792): Target WSGI script '/home/dev/wsgi-scripts/index.py' does
> not contain WSGI application 'application'.
> cat: last: No such file or directory
>
> --------------------------------------
> #!/usr/bin/env python
>
> import os
> from datetime import datetime
> import re
>
> class Handler:
> def do(self, environ, start_response):
>
> uri = environ['REQUEST_URI']
>
> html = "<html><head><title>Index of %s</title></head><body>" % uri
> html += "<h1>Index of %s</h1>" % uri
> html += "<table border='0'>"
> html += '<tr><th>Last
> Modified</th><th>Size</th>Description</th><th>Webifiable</th><tr><th
> colspan="6"><hr></th></tr>
> html += '<tr><td><a href="..">Parent
> Directory</a></td><td> </td><td align="right"> -
> </td><td> </td><td>&n
> html += '<tr><th colspan="6"><hr></th></tr>'
> html += "</tables>"
>
> html += "</body></html>"
>
> output = html
> mimeType = "text/html"
>
> status = "200 OK"
> response_headers = [("Content-type", mimeType),
> ("Content-length" , str(len(output)))]
>
> start_response(status, response_headers)
> return [output]
>
> def application(environ, start_response):
> handler = Handler()
> return handler.do(environ, start_response)
>
> ### Do I REALLY need to use wsgiref ??? Else how do I run 'application' ???
>
> if __name__ == '__main__' :
> ## Handler() ;;; will this do
> import wsgiref.handlers
> wsgiref.handlers.CGIHandler().run(application)
>
>
> >>
> >> <Directory "/opt/apache2215/htdocs">
> >> Options Indexes FollowSymLinks
> >> </Directory>
>
> FollowSymLinks changed to MultiViews
>
> TIA
>
> Nitin
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<modwsgi%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/modwsgi?hl=en.