简体   繁体   中英

Setting up mod_wsgi and pyramid on windows

I have been trying to set up pyramid under mod_wsgi in windows. My app is a simple scaffold created with the command

..\Scripts\pcreate -s starter it

My httpd.conf file has the following directives

LoadModule wsgi_module modules/mod_wsgi-win32-ap22py27-3.3.so
WSGIScriptAlias /x "C:/Documents and Settings/Administrator.TRANSGLOBAL/Desktop/env/pyramid.wsgi"
<Directory "C:/Documents and Settings/Administrator.TRANSGLOBAL/Desktop/env">
Order allow,deny
Allow from all
</Directory>

So all of my application code is in the folder it. The mod_wsgi.so file is loaded into apache and the following example code works in pyramid.wsgi

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

But when i change the pyramid.wsgi code to point to my pyramid application in named "it"

from pyramid.paster import get_app
import os
import sys
application = get_app('C:\Documents and Settings\Administrator.TRANSGLOBAL\Desktop\env\it\development.ini', 'main')

Apache logs produces the following error

File "C:/Documents and Settings/Administrator.TRANSGLOBAL/Desktop/env/pyramid.wsgi", line 11, in <module>
application = get_app('C:\\Documents and Settings\\Administrator.TRANSGLOBAL\\Desktop\\env\\it\\development.ini', 'main')
File "C:\\Python27\\lib\\site-packages\\pyramid-1.4-py2.7.egg\\pyramid\\paster.py", line 31, in get_app
app = loadapp(config_name, name=section, relative_to=here_dir, **kw)

raise DistributionNotFound(req)  # XXX put more info here
DistributionNotFound: it

After a lot of experimentation i came to notice that all of the windows boxes (windows 7, windows 8 and windows server 2003) i used refused to use the files in the virtual env and looked for the it project files in c:/python27/Lib/sitepackages

The solution was setting up a dist package of my package

..\\Scripts\\python setup.py sdist

and then installing the application in dist folder just like any other application. My apache configuration remained the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM