Graham Dumpleton
graham.dumpleton at gmail.com
Mon Nov 30 20:29:39 EST 2009
Sorry, one more thing. You also need latest check out of mod_wsgi 4.0 development version from subversion trunk for mod_wsgi. It can be made to work with mod_wsgi 3.1, you would just need to instead use: WSGIHandlerScript /some/path/bridge.wsgi where that file contains: from apache.wsgi import * The mod_wsgi 4.0 version supports a direct module reference to WSGIHandlerScript to skip needing a handler script file. Graham 2009/12/1 Graham Dumpleton <graham.dumpleton at gmail.com>: > I forgot to mention there is no automatic code reloading. Thus, if > changing any of the .py files you need to do an Apache restart. > > The point is that this is just a proof of concept of WSGI bridge at > the moment. The intent would be to have separate package 'modpysfu' > which adds back all that automatic code reloading that mod_python had > as well as mod_python compatible interfaces for stuff. > > Graham > > 2009/12/1 Graham Dumpleton <graham.dumpleton at gmail.com>: >> 2009/11/26 Graham Dumpleton <graham.dumpleton at gmail.com>: >>> I have moved it to: >>> >>> http://bitbucket.org/grahamdumpleton/apswigpy/ >>> >>> I'll add some basic documentation on building and usage. >> >> Quick cheat sheet. >> >> 1. Do a checkout/pull latest code for apswigpy from bitbucket and >> install it. Need this as added a little bridge for WSGI to at least >> get things going. >> >> 2. Add following configuration to Apache. I had this inside its own VirtualHost. >> >> WSGIHandlerScript python-script (apache.wsgi) >> >> <Directory /Users/grahamd/Testing/modpysfu> >> WSGIProcessGroup %{GLOBAL} >> WSGIApplicationGroup modpysfu >> WSGIPassApacheRequest On >> >> AddHandler python-script .py >> >> Options MultiViews FollowSymLinks >> MultiviewsMatch Handlers >> >> Order allow,deny >> Allow from all >> </Directory> >> >> In my case that directory was what DocumentRoot for host was set to. >> >> You would need to Alias it in some way if don't want to do it for DocumentRoot. >> >> 3. Now dump '.py' files in that directory and access URL as if >> accessing them as static file. A couple of examples are: >> >> # hello.py >> >> from apache.httpd import * >> from apache.http_protocol import * >> >> def handler(r): >> output = '<html><body>Hello World!</body></html>' >> >> r.status = HTTP_OK >> ap_set_content_type(r, 'text/html') >> #ap_set_content_length(r, len(output)) >> ap_rwrite(output, r) >> ap_rflush(r) >> >> return OK >> >> # echo.py >> >> from apache.httpd import * >> from apache.http_protocol import * >> >> def handler(r): >> r.status = HTTP_OK >> ap_set_content_type(r, 'text/plain') >> >> for (name, value) in r.headers_in.items(): >> ap_rwrite('%s: %s\n' % (name, value), r) >> >> ap_rflush(r) >> >> return OK >> >> Note that this is raw SWIG binding, no mod_python specific additions >> at this point. Some things have had to be Pythonised such as APR >> tables as used by headers_in, but otherwise trying to keep truthful to >> APR/AP APIs. >> >> I know some things don't work, such as 'ap_set_content_length()'. Some >> issue with SWIG bindings type equivalence has to be worked out for >> that one and haven't had chance to read SWIG documentation. >> >> Graham >> >
|