mod_pylite?

Graham Dumpleton Graham.Dumpleton at gmail.com
Thu Jan 1 23:40:52 EST 2009


On Jan 2, 2:28 pm, excord80 <excor... at gmail.com> wrote:
> On Jan 1, 9:12 pm, s... at pobox.com wrote:
>
> >     >>http://broadcast.oreilly.com/2008/12/five-features-perl-5-needs-now.html
>
> >     >> and he mentions a neat-looking project called ``mod_perlite``. It
> >     >> sounds like it will be very handy. Anyone working on a
> >     >> ``mod_pylite``?  Has it been done before, maybe under a different
> >     >> name?
>
> > It's kind of hard to tell.  There's very little description of how
> > mod_perlite would be different than mod_perl other than it would be more
> > lightweight, presumably as mod_php somehow is.  That hardly seems like a
> > well-defined requirement document.
>
> > Doesmod_wsgifit the bill?http://www.rkblog.rk.edu.pl/w/p/mod_wsgi/
>
> I'm not sure if it fits the bill or not. The bill is two-fold:
>
> 1. The Apache module should present little risk to the admin who
> installs it. That is, it should not expose Apache's innards.
>
> 2. The Apache module should keep a Python instance running; run, for
> example, ``foo.py`` when a user accesses (for example) ``http://www.example.com/path/to/foo.py?baz=88``; pass baz=88 to foo.py in the
> usual way; and return whatever html that script spits out.
>
> I'm not familiar with php or ``mod_php``, but I suspect that setup
> does something very similar to what's described above. This might
> explain why it's so blasted easy to deploy php scripts and create
> small and simple sites (and even not-so-small/simple sites) with it.
>
> Doesmod_wsgifit that bill? I don't know. The docs seem to be athttp://code.google.com/p/modwsgi/w/list. Many of those are named
> "ChangesInVersionXXXX". I don't see any that named anything like
> "Introduction" or "BasicUsage" or "SimpleUsageLikeCGI" or even
> "Tutorial". So, my guess is that ``mod_wsgi`` doesn't fit the bill.

Have you looked up what the WSGI specification for Python even is?

  http://www.python.org/dev/peps/pep-0333/
  http://www.wsgi.org/wsgi/Learn_WSGI

Did you also read the front page of the wiki for mod_wsgi and follow
the main links it gives on the front page?

  http://code.google.com/p/modwsgi/
  http://code.google.com/p/modwsgi/wiki/InstallationInstructions
  http://code.google.com/p/modwsgi/wiki/DeveloperGuidelines

If you understand what WSGI is, then you will realise that mod_wsgi is
a very slim adapter for Apache that allows one to host any WSGI
application. In the way one normally uses it, the internals of Apache
are not exposed and do not need to be as the whole point of WSGI is
that it is a portable interface for hosting Python web applications on
various web hosting solutions and not Apache specifically.

Back to whether it is equivalent to mod_perlite, that really depends
on what mod_perlite does. If mod_perlite tries to enforce some sort of
page template system like how PHP does then no mod_wsgi is not
equivalent, as that isn't what WSGI itself is about. All WSGI is about
is providing a most minimal interface for communicating with the web
server, everything else has to be done by the application running on
top of it. Thus WSGI and mod_wsgi is a light as it can get, perhaps
even lighter than mod_perlite could be as it may have to embody the
templating system, form handling, session management etc etc etc.

This doesn't mean you couldn't use mod_wsgi to effectively achieve the
same thing though, it just means your most minimal templating system,
ie., like PHP or even closer to traditional Python CGI, needs to be
implemented as an application on top of WSGI. Rather than do the
dispatch in your WSGI application though, you can still use Apache to
do the dispatching to individual file based resource files with the
right configuration. How this could be done has been answered a number
of times on mod_wsgi list as others have already wanted to know about
how to do a PHP like solution in Python and so it has been discussed.

If you want to talk more about this, come over to the mod_wsgi list on
Google Groups.

Graham





More information about the Python-list mailing list