2

I'm trying to get mongrel2 to work with m2wsgi. What I need to do so I can see "Hello World!" in my browser? Mongrel2 is installed but any site configurations are not done yet.

def app(environ, start_response):
  start_response("200 OK", [('Content-Type', 'text/plain')])
  return ['Hello World!', ]

Trying to run it:

m2wsgi test

AssertionError: the specified app is not callable

I'm running Ubuntu Maverick.

raspi
  • 5,962
  • 3
  • 34
  • 51

2 Answers2

0

If Mongrel2 is not fully configured, as your "Mongrel2 is installed but any site configurations are not done yet" statement suggests, then it won't be able to find your app (the m2wsgi documentation is perhaps not as clear about this as it might be). Here's a tutorial on getting Mongrel2 set up and ready to connect to a WSGI app - it uses wsgid instead of m2wsgi, but I bet you can adapt it to your needs.

Brighid McDonnell
  • 4,293
  • 4
  • 36
  • 61
0

To m2wgi be able to load your app, it must be in your PYTHONPATH, so to be able to run your test app try copying the test.py module to somewhere in your PYTHONPATH or, easier, try this:

PYTHONPATH=.:$PYHTONPATH m2wsgi test.app tcp://127.0.0.1:9995

Assuming you have, in your mongrel2 config database, a route pointing to a handler with send_spec = tcp://127.0.0.1:9995 and recv_spec = tcp://127.0.0.1:9994. I tried this locally and it worked:

daltonmatos@jetta ~ [6]$ curl http://localhost/m2wsgi/
Hello World!daltonmatos@jetta ~ [7]$

Take a look at the blog post cited by Sean, you have a great idea on how to configure mongrel2 and setup your hosts/routes/handlers. Also give wsgid a try, maybe you like it =). It also has support for raw WSGI apps.

Gook luck and happy hacking!

Dalton Barreto
  • 601
  • 5
  • 3