Python as replacement for PHP?
kosh
kosh at aesaeion.com
Fri Feb 27 23:53:14 EST 2004
On Friday 27 February 2004 01:50 pm, Erik Johnson wrote:
> This is somewhat a NEWBIE question...
>
>
> So, I'm hoping there are some people out there that actually have some
> expereience with both Python & PHP and can give me some solid, informed
> advice about PHP vs. Python, in general and particularly on the following
> points: (NOT Python evangelism please: I've already heard most of it, I've
> espoused a pretty good dose myself - frankly, I'm willing to buy most of
> it, but I've got a serious business decision to make here).
Overall my company webme-eng.com has been doing websites/webapps for about 3
years now using zope and we are very happy with it. It has been a very
productive environment to work in and we have worked a lot on frameworks to
make writing our stuff faster. Usually we can do in 1 week what most of our
competitors take about 3 months to do.
>
> 1) PHP seems to have a pretty good integration/driver with PostgreSQL.
> If we were to switch to Python, what modules/drivers are available to talk
> to PosgreSQL and is it as functional as PHP's support?
>
I know there is postgres support in python however with zope we have worked
pretty much exclusively with the ZODB which is an object database used in
zope. It has worked well even for sites that have about 2GB of data.
> 3) Does Python have an analog to strtotime()? (For those not familiar
> with that function, it converts a wide range of date formats as string into
> time_t value. Can handle things like "now", "+24 hours", "-3 days",
> "yesterday 06:00PM MST", "January 23, 2004", "2004-02-26 18:00:00 -07",
> etc.)
Zope has a equiv to that that I think does just about all of those if not all
I have not tested all of them and it is part of the standard DateTime object
that is has so it is used pretty much everywhere.
>
> 4) I am vaguely aware of Apache's modpython. We are currently running
> apache, but I'm real green when it comes to configuring/running/managing
> Apache. I don't really understand what all modpython does for me. Generally
> allows Apache to foist off an HTTP request on a Python script to handle I
> assume, but maybe some kind soul can better inform me about what all
> modpython really does for me?
From what I understand mod_python just gets rid of the startup time for each
request. Overall I prefer to have apache proxy for an app server like zope
you might also want to look at twisted.
>
> 5) A PHP script can freely jump in and out of static HTML and script
> code with <?php ?> tags. This is sometimes handy. Can you do the same
> thing with Python?
There are ways to do stuff like that in zope pretty easily. It allows you to
mix in python and your code if you want but it also makes it pretty trivial
to make the items a seperate script object and call that.
>
> 6) Debugging: I'm aware there is a debugger for Python - I haven't
> really used it. Maybe there is a better way to do this using PHP, but right
> now when a PHP script isn't working right, I'm reduced to print statements
> and just re-running the script. Do you know a better way to do this in PHP?
> If I were doing things in Python, is there an easy way to generate an HTTP
> request from my browser, but stop the generating script and analyze it in a
> Python debugger?
Zope also logs all errors to an object called error_log in the root of the
site which has the full python traceback and the entire contents of the web
request that generated it. I find that a very useful feature for debugging.
You can also attach a regular python debugger to zope and twisted (iirc).
>
> 7) This goes back to #2, but we are looking at purchasing a PHP
> graphing package: http://www.aditus.nu/jpgraph/ If we could easily call
> PHP from within Python, then I guess that is a no brainer: we can use the
> PHP package. If not, then we are left answering the quesiton, can we call
> it as a forked process, and if so, is that too expensive? Do you know of
> comparable packages for Python?
There are many graphing packages for python designed for many kinds of work.
It should be pretty easy to find one that suits your purpose and use that.
>
>
> I think that's it for now. Thank you for taking the time to read my
> post and many thanks in advance to anyone who would be so kind as to reply.
> (direct response to ej at wellkeeper dot com greatly appreciated).
>
> -ej
Overall many people consider zope overkill for most web problems and they are
probably right. It is a huge complex beast but it is also very good at
solving large problems. It has a very flexible security model built into it,
your code runs inside a sandbox unless specifically exempted, there are a lot
of products designed to work with it and a lot of information on using it.
I have no problem recommending zope over php and from what I have read of the
twisted docs for woven I would recommend that over php also. Since python is
not designed as a "web" language I find that overall it has been pretty easy
to build larger solutions since a website is pretty much just a regular app
with an html front end and you can use all the wide ranging features that
python offers such as simpler to read code which makes maintainence easier.
You also gain access to the large library of code available in the form of
stuff like the python imaging library, reportlab, numpy etc.
More information about the Python-list
mailing list