can i use the python in apache like PHP??

Jon Brisbin mail at jbrisbin.net
Sat Sep 23 09:59:16 EDT 2000


I don't know if my last message went through...so I'll try again:

Cary O'Brien <cobrien at Radix.Net> wrote in message
news:8qi3vl$n1d$1 at saltmine.radix.net...

> 2) apache module, like mod_perl or mod_php (right).  There are several in
development.
>    See http://modules.apache.org, search for python.

This will definately speed up the processing of your request, but what I
wanted when I asked this question some time back (not on this newsgroup, but
of other programmers :-) was that I wanted, essentially, Embeded Python.

I have found that most of the other packages out there were too complicated
to get working right out of the box, and lacked the features I needed to
make it advantageous to use Python...I didn't want to have to write more
code in Python to do the same thing that PHP had a built-in function for.

<shamelessplug>
So I started my own sourceforge-hosted project:  Python ServerPages.  You
can download it at http://sourceforge.net/projects/pythonpages

Basically, you download the CGI script, install it in your cgi-bin or
comparable directory, then embed Python into your html pages, and use the
PSP script like this (assuming your embeded python page is called
pypage.html):
http://www.your-domain.com/cgi-bin/psp/html/pypage.html

Where html is a directory off your DOCUMENT_ROOT (i.e.
/usr/local/apache/htdocs/html )...the psp script then loads your pypage.html
file from disk, parses it for python code, optimizes it by stripping
newlines, creates a few neat-o objects that you can use in your page (i.e.
Request and Form objects for one), then executes your generated python
inside the scripts namespace.  Of course, you can also add an AddHandler
directive into your apache httpd.conf file if you would rather call the the
page like http://www.your-domain.com/html/pypage.pyml ...it's completely
your choice :-)

It's only in Alpha stage, but I've already been able to do more with it than
the other packages that contained a large number of files to keep track of
and configure.

Right now, it's not very configurable (unless you edit the source, of course
:-), but it's under heavy development, so expect it to be somehting close to
Embeded PERL ( http://perl.python.org/embperl ), only for python :-)
</shamelessplug>

> 3) Zope.  Zope is a big web application engine built on python.  See
http://www.zope.org.
>
> I'm a big Zope fan, but it can be a bit intimidating if you are in a
hurry. If you are
> in a hurry, the cgi module looks like the quickest way to get up and
running if you
> know a bit of python.  If you are a big PHP fan, go for solution 2.

I really liked Zope, and I tried to use it in production, but my designers
want to edit files from a hard disk and not use the sometimes tedious
web-based interface.  I liked it myself, but I'm not a good dictator :-)  It
had the features I wanted, but for most of the little stuff, it wasn't
cost-effective to use it because it took a while to get things up and
running.

I just wanted something that would allow me to code in Python, and do it
quickly.  Since I couldn't find anything already written that was very
small, lightweight, and versatile, I just had to "roll my own" :-)

Jon Brisbin
www.jbrisbin.net

Python ServerPages  http://sourceforge.net/projects/pythonpages
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Email:  mail at jbrisbin.net
eFax.com Fax/Voice mailbox:  208.545.5368
PGP public key: http://www.jbrisbin.net/pgpkey.shtml
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

>
>
> have fun!
>
> -- cary





More information about the Python-list mailing list