473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Python for Webscripting (like PHP)

Hello,
I've been using Python a lot for scripting (mainly scripts for server
administration / DB access). All these scripts were shell based.

Now I'm considering using Python (with mod_python on Apache 2) for a web
project, just how I've used PHP in some smaller Projects before (<?php
print "foo" ?>)..

How suitable is Python for these kind of projects? What do think? Does the
stdlib offers all basic functions for this kind of requirements?

Thanks,

Florian
Aug 18 '05 #1
27 2031
Florian Lindner ha scritto:
Hello,
I've been using Python a lot for scripting (mainly scripts for server
administration / DB access). All these scripts were shell based.

Now I'm considering using Python (with mod_python on Apache 2) for a web
project, just how I've used PHP in some smaller Projects before (<?php
print "foo" ?>)..

How suitable is Python for these kind of projects? What do think? Does the
stdlib offers all basic functions for this kind of requirements?


You can use the Python Server Pages, that are analogous to ASP, PHP and JSP.
<http://www.webwareforpython.org/>
<http://www.webwareforpython.org/Webware/PSP/Docs/index.html>

--
<http://robiweb90.blogspot.com>
robiweb90 [at] gmail [dot] com
"Nessuno può fabbricare una macchina tanto intelligente che possa essere
usata da uno sciocco" - Confucio
Aug 18 '05 #2
I don't think stdlib offers anything like that

The problem with python is it's white space sensible and html is not.

However there are some nice solutions:
http://www.webwareforpython.org/Papers/Templates/
my favourite is not listed here:
http://karrigell.sourceforge.net/

For web development with python i'd rather recommend a complete
webframework:
http://www.djangoproject.com/
http://subway.python-hosting.com/
http://www.zope.org/

nszabolcs

Aug 18 '05 #3
Florian Lindner wrote:
How suitable is Python for these kind of projects? What do think? Does the
stdlib offers all basic functions for this kind of requirements?


Python is extremely well suited for the web-app development and the STDLib
supply most of what you need for this task. As a matter of fact, the easy
development of web applications was one of the main focuses of the Python
community since Rel 1.0. Thanks to the hard work of its supporters, Python
is now widely considered one of the best tool you can use for developing
web applications, even better than PHP.

Have a look at these chapters of the official Python documentation to get
convinced of what I'm saying:
Chap. 11: Internet Protocols and Support
Chap. 12: Internet Data Handling
Chap. 13: Structured Mark-Up Languages Processing

(Python has even been told to be used by Yahoo! and Google, among others,
but nobody was able to demonstrate this, so far)

Despite this, keep in mind that developing a _real_world_ web application
without the right tools (session management and templating, in particular)
is quite hard, no matter which language you use (even with PHP).

Have a look at the many web frameworks mentioned at http://www.python.org/
and at http://www.vex.net/parnassus/ and choose the one you feel best
suited for your task.

Among these web framework, a couple of them deserve a particular attention:

Maki is a XML based framework, very similar to the java-based Cocoon:
http://maki.sourceforge.net/
http://cocoon.apache.org/

Albatross is aimed to stateful applications:
http://www.object-craft.com.au/projects/albatross/

Regarding the template engine, the best one I'm aware of is Cheetah:
http://www.cheetahtemplate.org/

A last word: beware of PSP (Python Server Pages). If used in the wrong way,
this tool (like the original Java Server Pages) can make a real mess of
your code (because of the inextricable tangle of Python and HTML code you
can create).

CU

-----------------------------------
Alessandro Bottoni
Aug 18 '05 #4
Mod_python has a PSP (python server pages - ala php) implementation.
However it's still not mature enough and, imho, it has a serious
drawback in its way to handle indentation. But this is just the first
release and I hope it will improve in the near future.

My favorite is Karrigell ( http://karrigell.sourceforge.net ).
It is a pleasure to work with, minimalistic, simple and to the point.
No template language needed, just regular python and html and, as far
as I know, mod_python integration is uderway.

Hope it helps...
Luis

Aug 18 '05 #5
Alessandro Bottoni <al****************@infinito.it> wrote:
(Python has even been told to be used by Yahoo! and Google, among others,
but nobody was able to demonstrate this, so far)


?

Google and Microsoft and Nokia had talks during PyCon 2005.
If you look at the GMAIL help system you would see that all the links in
there end in .py.
Blogger is almost completely built with python.
Google is also one of the members of the PSF.

What should be demonstrated?

--
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.4
Blog: http://vvolonghi.blogspot.com
http://weever.berlios.de
Aug 18 '05 #6
Alessandro Bottoni wrote:
(Python has even been told to be used by Yahoo! and Google, among others,
but nobody was able to demonstrate this, so far)


Nobody, except Google's founders?

http://www-db.stanford.edu/~backrub/google.html

(Among many other references.)

-Peter
Aug 18 '05 #7
Peter Hansen wrote:
Alessandro Bottoni wrote:
(Python has even been told to be used by Yahoo! and Google, among others,
but nobody was able to demonstrate this, so far)

Nobody, except Google's founders?

http://www-db.stanford.edu/~backrub/google.html

(Among many other references.)

-Peter


Plus, may I remind the world, PyCon DC 2005 had a keynote by far-from
obscure Python supporter Greg Stein, an engineering manager at Google,
giving a talk entitled "Python at Google".

There's informal evidence that the Python secret is getting out. Sharpen
up your resumes, guys, you may not have to limit Python to home usage
soon :-)

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Aug 18 '05 #8
Alessandro Bottoni wrote:
(Python has even been told to be used by Yahoo! and Google, among others,
but nobody was able to demonstrate this, so far)


If you use Yahoo! Maps, you will notice they use Python.

Scott

Aug 18 '05 #9
In article <ma***************************************@python. org>,
Steve Holden <st***@holdenweb.com> wrote:

There's informal evidence that the Python secret is getting out. Sharpen
up your resumes, guys, you may not have to limit Python to home usage
soon :-)


OTOH, the big sucking sound from Google and Yahoo (plus other places
like Ironport) is making it more difficult to hire Python programmers in
the Bay Area...
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
Aug 18 '05 #10

"Peter Hansen" <pe***@engcorp.com> wrote in message
news:yP*****************************************@p owergate.ca...
Alessandro Bottoni wrote:
(Python has even been told to be used by Yahoo! and Google, among
others,
but nobody was able to demonstrate this, so far)


Nobody, except Google's founders?

http://www-db.stanford.edu/~backrub/google.html


I think the relevant paragraph is worth quoting here (****s added):
"
In order to scale to hundreds of millions of web pages, Google has a fast
distributed crawling system. A single URLserver serves lists of URLs to a
number of crawlers (we typically ran about 3). Both the URLserver and the
crawlers are implemented in **Python**. Each crawler keeps roughly 300
connections open at once. This is necessary to retrieve web pages at a fast
enough pace. At peak speeds, the system can crawl over 100 web pages per
second using four crawlers. This amounts to roughly 600K per second of
data. A major performance stress is DNS lookup. Each crawler maintains a
its own DNS cache so it does not need to do a DNS lookup before crawling
each document. Each of the hundreds of connections can be in a number of
different states: looking up DNS, connecting to host, sending request, and
receiving response. These factors make the crawler a complex component of
the system. It uses asynchronous IO to manage events, and a number of
queues to move page fetches from state to state.
"
This seems to have been about 2000. Of course, bottleneck code may have
been rewritten in C, but Google continues to hire Python programmers (among
others).

Terry J. Reedy

Aug 18 '05 #11
On 18 Aug 2005 10:58:46 -0700, Aahz <aa**@pythoncraft.com> wrote:
OTOH, the big sucking sound from Google and Yahoo (plus other places
like Ironport) is making it more difficult to hire Python programmers in
the Bay Area...


Then start looking for telecommuting people. There are lots of us who
can use work and have excellent telecommuting references, but who
don't happen to live in a major metro area!
--

# p.d.
Aug 19 '05 #12
Peter Decker wrote:
Then start looking for telecommuting people. There are lots of us who
can use work and have excellent telecommuting references, but who
don't happen to live in a major metro area!


And then there's some in the Bay Area who wouldn't mind telecommuting,
either ... :-)

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
There is no present or future; only the past, happening over and over
again, now. -- Eugene O'Neill
Aug 19 '05 #13
Aahz wrote:
In article <ma***************************************@python. org>,
Steve Holden <st***@holdenweb.com> wrote:
There's informal evidence that the Python secret is getting out. Sharpen
up your resumes, guys, you may not have to limit Python to home usage
soon :-)

OTOH, the big sucking sound from Google and Yahoo (plus other places
like Ironport) is making it more difficult to hire Python programmers in
the Bay Area...


Not to mention the large Python gravity field a few hundred miles South
emanating from Industrial Light and Magic.

But don;t expect "Google and Yahoo suck" to be a popular compaint ;-)

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Aug 19 '05 #14
Yes the stdlib offers all the basic functions, but why work so hard?
Get CherryPy (http://www.cherrypy.org) and relax a bit. You'll be able
to concentrate on Python for the backend, HTML for the frontend,
without a lot of directory-diddling.

Also, check out
http://www-128.ibm.com/developerwork...ndex.html#main
for a nice, fresh slice.

Ron

Aug 19 '05 #15
I like the look of cheeryPy - snyone know if its easy to get it
running on top of Apache?

Thanks

On 19 Aug 2005 04:10:23 -0700, paron <rp*******@engineer.co.summit.oh.us> wrote:
Yes the stdlib offers all the basic functions, but why work so hard?
Get CherryPy (http://www.cherrypy.org) and relax a bit. You'll be able
to concentrate on Python for the backend, HTML for the frontend,
without a lot of directory-diddling.

Also, check out
http://www-128.ibm.com/developerwork...ndex.html#main
for a nice, fresh slice.

Ron

--
http://mail.python.org/mailman/listinfo/python-list

Aug 19 '05 #16
'cherryPy' even

On 8/19/05, Jon Hewer <jo******@gmail.com> wrote:
I like the look of cheeryPy - snyone know if its easy to get it
running on top of Apache?

Thanks

On 19 Aug 2005 04:10:23 -0700, paron <rp*******@engineer.co.summit.oh.us>wrote:
Yes the stdlib offers all the basic functions, but why work so hard?
Get CherryPy (http://www.cherrypy.org) and relax a bit. You'll be able
to concentrate on Python for the backend, HTML for the frontend,
without a lot of directory-diddling.

Also, check out
http://www-128.ibm.com/developerwork...ndex.html#main
for a nice, fresh slice.

Ron

--
http://mail.python.org/mailman/listinfo/python-list

Aug 19 '05 #17
Yes, there's a tutorial about that -- there are several options
depending on the URL structure you want to expose, and your version of
Apache. None of them are torturous, though.

Start at http://www.cherrypy.org/wiki/CherryPyProductionSetup and
follow the links down.

Ron

Aug 19 '05 #18
Ah cool, thanks, i hadn't spotted that page

:)

On 19 Aug 2005 04:51:06 -0700, paron <rp*******@engineer.co.summit.oh.us> wrote:
Yes, there's a tutorial about that -- there are several options
depending on the URL structure you want to expose, and your version of
Apache. None of them are torturous, though.

Start at http://www.cherrypy.org/wiki/CherryPyProductionSetup and
follow the links down.

Ron

--
http://mail.python.org/mailman/listinfo/python-list

Aug 19 '05 #19
Florian Lindner wrote:
Hello,
I've been using Python a lot for scripting (mainly scripts for server
administration / DB access). All these scripts were shell based.

Now I'm considering using Python (with mod_python on Apache 2) for a web
project, just how I've used PHP in some smaller Projects before (<?php
print "foo" ?>)..

How suitable is Python for these kind of projects? What do think? Does the
stdlib offers all basic functions for this kind of requirements?


An email I got from Dan Richter. Since he has problems with his news/mail
gateway I forward it with his permission for the benefit of others.

Florian

- - -

Python is great for "heavy lifting": when most of the work is done
behind the scenes and outputting the HTML is relatively trivial. An
example would be a program that searches archives or computes
derivatives.

But PHP is designed for web pages and is quite powerful. If you can
reasonably do a job in PHP, you probably should. Web sites written in
Python usually involve lots of statements like these:
uri = os.environ['HTTP_URI']
print '<html><head><title>' + theTitle + '</title></head>'
print '''<body><div>
<h1>The answer to your question</h1>
<p>After lots of computing, here's what
we discovered.</p>'''
And so on. As you can see, PHP allows you to embed HTML much more
gracefully, as well do other web-like things such as retrieve URL query
string parameters more easily. So PHP is preferable for most web sites.

Depending on what you want to do, you might also consider Perl and Java
Servlets.

- - -
Aug 19 '05 #20
You might want to check out spyce. It uses a server page model (like
jsp and php) so you can embed python in html. It has the standard stuff
you would need for making a web site (session support, etc) and also
contains features like custom tags.

http://spyce.sourceforge.net/

Aug 19 '05 #21
In article <Ks*****************************************@speak easy.net>,
Erik Max Francis <ma*@alcyone.com> wrote:
Peter Decker wrote:

Then start looking for telecommuting people. There are lots of us who
can use work and have excellent telecommuting references, but who
don't happen to live in a major metro area!


And then there's some in the Bay Area who wouldn't mind telecommuting,
either ... :-)


We do a *lot* of telecommuting. I'm working from home today, for
example, because I needed to deal with the plumber. And we have two
people in Seattle out of seven fulltime people. However, it's our
experience that people are more productive when they show up at the
office regularly -- the two Seattle people had lots of experience with
our product before they worked independently, and the two of them do
share an office.

(They work across the street from Elliott Bay Books, the bastards.)
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
Aug 19 '05 #22

"Gregory Piñero" <gr********@gmail.com> wrote in message
news:31************************@mail.gmail.com...
I'd love Python work, just like everyone else here. On a related topic,
what's the >policy/etiquette of posting a resume on here, or mentioning
what kind of work >you're looking for?
I would take absence of such postings, even though you can imagine *lots*
of people have had the same idea, as an indication that it is against
policy/etiquette. If 1 person does it, we could easily have 10 or 100 a
day ;-).
And what's the policy in general for most newsgroups and mailing lists?


For mainline newsgroups, such as the comp.*, commercial annoucements are
generally counter-indicated unless the name (.marketplace) or charter say
otherwise. Exceptions would be a low volume of things of direct and narrow
interest. So I consider the rare job announcements posted here ok. The
same for book announcements. In either case, such are positive news for
what is still a minority, just becoming mainstream, language.

Terry J. Reedy

Aug 19 '05 #23
"Terry Reedy" <tj*****@udel.edu> writes:
generally counter-indicated unless the name (.marketplace) or charter say
otherwise. Exceptions would be a low volume of things of direct and narrow
interest. So I consider the rare job announcements posted here ok. The
same for book announcements.


The key words here are "of direct and narrow interest". Job postings
that don't mention Python in c.l.python are spam, nothing else.

Maybe the Python jobs lists needs a "available developers"
counterpart? Or would it be to big/dynamic to maintain using whatever
is behind the jobs list?

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Aug 20 '05 #24
In article <86************@bhuda.mired.org>, Mike Meyer <mw*@mired.org> wrote:

Maybe the Python jobs lists needs a "available developers"
counterpart? Or would it be to big/dynamic to maintain using whatever
is behind the jobs list?


Part of the reason the Jobs page hasn't moved to a wiki is that often
people sending in job ads are insufficiently technical to handle the
formatting. That presumably wouldn't be true for an "available
developers" wiki...
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
Aug 20 '05 #25
Alessandro Bottoni wrote:
(Python has even been told to be used by Yahoo! and Google, among others,
but nobody was able to demonstrate this, so far)


hint:

http://mail.google.com/support/bin/a...py?answer=6554

</F>

Aug 22 '05 #26
"Fredrik Lundh" <fr*****@pythonware.com> writes:
(Python has even been told to be used by Yahoo! and Google, among others,
but nobody was able to demonstrate this, so far)

hint:
http://mail.google.com/support/bin/a...py?answer=6554


I don't see anything about Python at that url. I've heard Gmail is
written in Java. Google is well known to use Python for many internal
purposes, and perhaps for some low traffic administrative web pages.
The main search application is written in C++ and is enormous.
I haven't heard that any high traffic pages are handled in Python.
Aug 22 '05 #27
On 22 Aug 2005 09:16:41 -0700, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
"Fredrik Lundh" <fr*****@pythonware.com> writes:
(Python has even been told to be used by Yahoo! and Google, among others,
but nobody was able to demonstrate this, so far)

hint:
http://mail.google.com/support/bin/a...py?answer=6554


I don't see anything about Python at that url.


Don't look at the page the URL returns - look at the URL itself. ;-)

--
Cheers,
Simon B,
si***@brunningonline.net,
http://www.brunningonline.net/simon/blog/
Aug 22 '05 #28

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Erik Johnson | last post by:
This is somewhat a NEWBIE question... My company maintains a small RDBS driven website. We currently generate HTML using PHP. I've hacked a bit in Python, and generally think it is a rather...
40
by: Shufen | last post by:
Hi all, Can someone who has use PHP before and know quite well about the language, tell me what are the stuffs that Python offers and PHP doesn't. A few examples will be nice. I know about the...
22
by: stephen.mayer | last post by:
Anyone know which is faster? I'm a PHP programmer but considering getting into Python ... did searches on Google but didn't turn much up on this. Thanks! Stephen
69
by: notbob | last post by:
I'm not posting this just to initiate some religious flame war, though it's the perfect subject to do so. No, I actaully want some serious advice about these two languages and since I think usenet...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.