4

This is what I found that in theory should work from git hub.com passenger-pylons-wsgi-example

import os, sys                                                                                                                                          
sys.path.append('/home/user/test.sample.com/Helloworld')                                                                     
os.environ['PYTHON_EGG_CACHE'] = '/home/user/tmp'   

from paste.deploy import loadapp                                                                                                                        

def application(environ, start_response):                                                                                                               
    environ['SCRIPT_NAME'] = environ['PATH_INFO']                                                                                                       
    application = loadapp('config:/home/user/test.sample.com/production.ini')                                    
    return application(environ, start_response)

Tried it on dreamhost and I get:

An error occurred importing your passenger_wsgi.py

I also tried the virtual environment but it didn't seem to work either.

mind you after following the instructions I have python 2.6 but no activate in the virtual directory.

Any ideas?

I also tried adding:

from fcgi import WSGIServer

and after the def application:

server = WSGIServer(application)
server.run()

But still get the same error. I wish it was a bit more descriptive so I could debug the passenger_wsgi

cmcginty
  • 113,384
  • 42
  • 163
  • 163
Dean
  • 302
  • 1
  • 8

1 Answers1

4

Finally found my answer:

import os, sys                                      
INTERP = "/home/user/local/bin/python" 
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)                                                                                                   
sys.path.append('/home/user/test.sample.com/Helloworld')                                                                     
os.environ['PYTHON_EGG_CACHE'] = '/home/user/tmp'   

from paste.deploy import loadapp                                                                                                                        

def application(environ, start_response):                                                                                                               
    environ['SCRIPT_NAME'] = environ['PATH_INFO']                                                                                                       
    application = loadapp('config:/home/denat/test.sample.com/production.ini')                                    
    return application(environ, start_response)

The difference here is that the virtual environment was setup with pylons but wasn't using it. From the wiki on dreamhost I needed to add the following lines:

INTERP = "/home/user/local/bin/python" 
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)               

I now have a working pylons app! Yay!

I know others have been looking for this so I hope this helps them.

cmcginty
  • 113,384
  • 42
  • 163
  • 163
Dean
  • 302
  • 1
  • 8
  • Did you ever have any problem with getting "premature end of script headers" for your Pylons project on Dreamhost? My main/default Pylons page appears... but when I try to go to a controller's action page (www.site.com/controller/action) I just get a 500 Internal Server Error... the Pylons app itself works when run using the "localhost" server... but when I check the Pylons app via Passenger, I get that 500 error... heh heh – summea Oct 18 '12 at 15:56
  • 1
    in the 500 error you should be able to see the log file on dreamhost in the logs/www.site.com/ This should help you debug it. Without the code I can't say where the problem is. I hope this helps. – Dean Nov 09 '12 at 18:14
  • Thanks for the comment; after a while, I think I ended up getting some logging going after reading through some of the DreamHost wiki pages related to WSGI :) Thanks again! – summea Nov 10 '12 at 17:22