On Dec 10, 5:32 am, "Graham Dumpleton" <[EMAIL PROTECTED]>
wrote:
> I have been asked something similar a number of times. I don't know
> why but it is always to me direct and not on the mailing list. Not
> sure if it means the others were embarrassed about their yearnings for
> something more like PHP or not. ;-)
>
> Anyway, what you are wanting is not WSGI. That said, it doesn't mean

even if it's not WSGI, it would be nice to leverage the standards
established by WSGI and be able to plug-in some of the middleware in
the same way as a traditional WSGI application.

> that you cannot write a WSGI application which acts as an intermediary
> or proxy to interpret the files contents however you want. In effect
> you are just creating a variant of a Python templating system. Rather
> than you independently having to implement all the URL dispatch
> yourself though, one can use aspects of Apache configuration to allow
> Apache to do it for you. The result isn't strictly a pure WSGI
> application as it will only work under Apache/mod_wsgi, but if you
> don't care, then that is not an issue.

having Apache perform URL dispatch as the default behavior is
preferred as Apache/mod_wsgi is the primary target currently but also
because the hope would be that it could be set up similarly without
too much effort in other environments (nginx, IIS).  Ideally this
would also allow the developer to simultaneously to do WSGI style URL
dispatch if they need to.

>
> Quoting some bits from prior mails I have sent about this ....
>
> The Apache configuration you want is:
>
>  Action pyhp-scripts /pyhp-interpreter
>  WSGIScriptAlias /pyhp-interpreter /some/path/pyhp.wsgi
>  AddHandler pyhp-scripts .pyhp
>
> You would then put your .pyhp files where ever you want in directories
> covered by the AddHandler. When ever a request comes in for a file
> with .pyhp extension, Apache will actually invoke WSGI application at
> /pyhp-interpreter to handle the request.
>
> The WSGI environ for the WSGI application would be something like:
>
> DOCUMENT_ROOT: '/Library/WebServer/Documents'
> GATEWAY_INTERFACE: 'CGI/1.1'
> HTTP_ACCEPT: 
> 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain; 
> q=0.8,image/png,*/*;q=0.5'
> HTTP_ACCEPT_ENCODING: 'gzip, deflate'
> HTTP_ACCEPT_LANGUAGE: 'en-us'
> HTTP_CONNECTION: 'keep-alive'
> HTTP_HOST: 'localhost'
> HTTP_USER_AGENT: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5;
> en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2
> Safari/525.20.1'
> PATH: '/usr/bin:/bin:/usr/sbin:/sbin'
> PATH_INFO: '/~grahamd/foo.pyhp'
> PATH_TRANSLATED: '/Users/grahamd/Sites/foo.pyhp'
> QUERY_STRING: ''
> REDIRECT_HANDLER: 'pyhp-scripts'
> REDIRECT_SCRIPT_URI: 'http://localhost/~grahamd/foo.pyhp'
> REDIRECT_SCRIPT_URL: '/~grahamd/foo.pyhp'
> REDIRECT_STATUS: '200'
> REDIRECT_URL: '/~grahamd/foo.pyhp'
> REMOTE_ADDR: '::1'
> REMOTE_PORT: '50491'
> REQUEST_METHOD: 'GET'
> REQUEST_URI: '/~grahamd/foo.pyhp'
> SCRIPT_FILENAME: '/Users/grahamd/Sites/echo.wsgi'
> SCRIPT_NAME: '/pyhp-interpreter'
> SCRIPT_URI: 'http://localhost/~grahamd/foo.pyhp'
> SCRIPT_URL: '/~grahamd/foo.pyhp'
> SERVER_ADDR: '::1'
> SERVER_ADMIN: '[EMAIL PROTECTED]'
> SERVER_NAME: 'localhost'
> SERVER_PORT: '80'
> SERVER_PROTOCOL: 'HTTP/1.1'
> SERVER_SIGNATURE: ''
> SERVER_SOFTWARE: 'Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l
> DAV/2 mod_wsgi/3.0-TRUNK Python/2.5.1'
> mod_wsgi.application_group: 'graham-dumpletons-imac-2.local|/pyhp-interpreter'
> mod_wsgi.callable_object: 'application'
> mod_wsgi.listener_host: ''
> mod_wsgi.listener_port: '80'
> mod_wsgi.process_group: '~grahamd'
> mod_wsgi.script_reloading: '1'
> mod_wsgi.version: (3, 0)
> wsgi.errors: <mod_wsgi.Log object at 0x1007888d0>
> wsgi.file_wrapper: <built-in method file_wrapper of mod_wsgi.Adapter
> object at 0x100726a80>
> wsgi.input: <mod_wsgi.Input object at 0x10077fcb0>
> wsgi.multiprocess: False
> wsgi.multithread: True
> wsgi.run_once: False
> wsgi.url_scheme: 'http'
> wsgi.version: (1, 0)
>
> The actual file which was the matched target of the request would be
> in 'PATH_TRANSLATED'. The WSGI application would then read and process
> that file however it wants. This might include it parsing file,
> converting it into executable Python code, performing caching and only
> rereading files from disk when target file changes etc etc. What you
> do is really up to you at this point, but at least Apache has done the
> URL dispatching to file based resources for you so you do not have to
> worry about that.
>
> Graham

Great - thanks for the configuration tips above!!  I will give it a go
and see if it works as envisioned.  Hopefully the result will be a PHP-
style templating system that provides most of the benefits of a WSGI
application.

-Walter
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to modwsgi@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to