Using Python for my web site

G

Gerhard Fiedler

My point is to stop FUD right at that comment. I don't doubt your
research from "a few years ago", but ancient research is entirely
irrelevant for making a decision *today*.

That's exactly the reason why I added this information. It might not be for
you, but it is interesting for me (and might be for someone else) to see
that I get a different feedback now than I got a few years ago. It tells
something about the dynamic of the process that the mere status of today
doesn't tell.

Besides, "claimed to have" and "seemed to have" are not really FUD inducing
terms :)

Anyway, I appreciate you sharing your experience (which in that area
certainly is more than mine).

Gerhard
 
C

Cliff Wells

That's exactly the reason why I added this information. It might not be for
you, but it is interesting for me (and might be for someone else) to see
that I get a different feedback now than I got a few years ago. It tells
something about the dynamic of the process that the mere status of today
doesn't tell.

Well, perhaps I misunderstood your intent. Sorry if I was short.
Besides, "claimed to have" and "seemed to have" are not really FUD inducing
terms :)

Taken in a vacuum, they can certainly add to an overall negative
impression. PostgreSQL, in the past, has certainly had some hurdles
that made it a suboptimal choice for many people: performance and
difficulty in installation and management, among other things (I've
personally not had stability issues), lack of a native Win32 version,
etc, have made it the runner up in deployment to MySQL.
Today, that's all changed. PostgreSQL is comparable in performance to
MySQL (although I expect each outperforms the other in certain areas),
*easier* to install and maintain than MySQL, and its stability is
outstanding. Release 8 also saw a native Windows version. For many
reasons, MySQL seems to be on the reverse track, sacrificing
performance, stability and ease of use in an attempt to catch up to
PostgreSQL in features.
Nevertheless, there remains rumors and myths that stem from those old
days that cause many people to fear deploying PostgreSQL. This is part
of the reason I'm always quick to jump on statements such as yours. I
feel it's a disservice to the community to let those myths continue and
perhaps dissuade others from discovering what is today *the* premier
FOSS relational database.
Anyway, I appreciate you sharing your experience (which in that area
certainly is more than mine).

I'm glad I was able to add to the pool of knowledge (or at least the mud
puddle of anecdote).

Cliff

--
 
?

=?iso-8859-1?q?Luis_M._Gonz=E1lez?=

I don't have experience with Django or any other python framework, but
I have used bare-bones mod_python and it rocks.
I wouldn't use PSP though...
It is not very polished, and they way it handles the "indentation
problem" in python is a little bit confussing.

IMHO the best way of using mod_python is with its publisher handler.
It let's you code your applications in a MVC (model view controller)
style.
This way you can cleanly separate presentation and logic, making your
code more concise, clear and mantainable.

With publisher, every function defined in your script represents a web
page in your site, and the html code can be moved to a template, that
could be PSP itself or Cheetah, for example (Cheetah is very good).

A very simple example:

#mysite.py

def index(req):
req.content_type = 'text/html'
req.write("""
<form action = mysite.py/printMyName method = post>
<input type = text name = myname>
<input type = submit>
""")

def printMyName(req, myname):
req.content_type = 'text/html'
req.write(myname)

# end of mysite.py

In this script, the function "index" is executed by default when you go
to http://yourserver/mysite.py, and it displays a text box and a submit
button.
(The first line indicates that the output will be in html format, and
"req.write" is equivalent to "print".)

If you enter your name and hit the submit button, your name is passed
to the "printMyName" function and printed in your browser's screen.

This way, both functions can be viewed like two separate pages within
your site.
So, with only one script, you can write a whole site if you want.

For more complex pages where html is used, you can place this
presentation code in templates, and then import them into your main
script.
Or else, you could simple use "req.write" to print your html directly
(as I did in "index").
Hope this helps...

Luis
 
C

Cliff Wells

I don't have experience with Django or any other python framework, but
I have used bare-bones mod_python and it rocks.
I wouldn't use PSP though...
It is not very polished, and they way it handles the "indentation
problem" in python is a little bit confussing.

IMHO the best way of using mod_python is with its publisher handler.
It let's you code your applications in a MVC (model view controller)
style.

While I agree (or at least consider the point moot) that this is
possibly the best way to use plain mod_python, I'd disagree that it's a
good way to develop modern web applications in Python. By the time
you've decided on every bit of framework to use, and made all the little
decisions that go into turning a fresh, clean spot on your hard drive
into an application, what you've done is reinvent TurboGears rather than
develop your application. Worse, you've probably reinvented it poorly.
I've done so many times and am well aware of what a time-waster it is.

You say that you haven't tried Django or any other Python framework.
Perhaps you should. You seem to have at least the start of the right
idea about web application organization, so I think you'd be pleasantly
surprised with what you'll find already done for you by the major Python
frameworks and how much time you'll stop wasting on code that isn't part
of your application.

Regards,
Cliff
 
B

bryanjugglercryptographer

northband said:
Hi, I am interested in re-writing my website in Python vs PHP but have
a few questions. Here are my specs, please advise as to which
configuration would be best:

1.Dell Poweredge Server, w/IIS, currently Windows but considering
FreeBSD
2. Site consists of result pages for auctions and items for sale (100
per page)
3. MySQL (Dell Poweredge w/AMD) database server connected to my web
server
4. Traffic, 30 million page loads/month

I am trying to have the fastest page loads, averaging 100 items per
result page. I have read about using Apache's mod_python so I could
use PSP. Any help or tips are appreciated.

So if I'm reading this correctly: you have a system that's
working, and the main purpose of the re-write is faster page
responses to users. Do I have that right?

Have you determined where the time is spent? For some web apps,
speed is all about the database, and if that's true of your system
then changing scripting language isn't going to provide the
performance boost you seek.

Another interesting question is how response time changes with
increasing load. Of course with the real website, those 30 million
page loads per month are not uniformly distributed. What is your
peak rate? Is rush-hour speed mostly what motivates the project?
 
P

Paul Boddie

[Specifications]
I am trying to have the fastest page loads, averaging 100 items per
result page. I have read about using Apache's mod_python so I could
use PSP. Any help or tips are appreciated.

So if I'm reading this correctly: you have a system that's
working, and the main purpose of the re-write is faster page
responses to users. Do I have that right?

Performance is clearly important, but later on the questioner says...

Q> Currently our site is built with a closed source hypertext
Q> preprocessor much like PHP.

That sounds like a good enough reason for migration, depending on how
unportable, unsustainable or unmaintainable the technology platform has
proven itself to be. Still, at least the questioner isn't seeking
performance by wanting to rewrite everything in C++...

Paul
 
N

northband

Awesome response, thanks. I am definitely interested in the MVC and am
looking into it now.

Yes, we are migrating to Python mainly because we want unicode support,
more stability, and faster performance than what we are getting now.
We were going to move to php but seem python is the better choice, plus
php 5.0 still doesn't support unicode.

-Adam O
 
?

=?iso-8859-1?q?Luis_M._Gonz=E1lez?=

Cliff said:
While I agree (or at least consider the point moot) that this is
possibly the best way to use plain mod_python, I'd disagree that it's a
good way to develop modern web applications in Python. By the time
you've decided on every bit of framework to use, and made all the little
decisions that go into turning a fresh, clean spot on your hard drive
into an application, what you've done is reinvent TurboGears rather than
develop your application. Worse, you've probably reinvented it poorly.
I've done so many times and am well aware of what a time-waster it is.

You say that you haven't tried Django or any other Python framework.
Perhaps you should. You seem to have at least the start of the right
idea about web application organization, so I think you'd be pleasantly
surprised with what you'll find already done for you by the major Python
frameworks and how much time you'll stop wasting on code that isn't part
of your application.

Regards,
Cliff

Well... yes, you're right.
I guess that the reason for not having used a framework already is
laziness...
I have experience with Karrigell, which rocks too, but it lacks some
deployment options (no mod_python, no fastcgi, etc).

And as far as I could see in the Django docs, I should learn many new
things to do exactly the same, such as yet another templating language
or how to map urls with regular expressions (I still couldn't wrap my
head around regex... I find them very boring to learn...). But you are
absolutely right. I should definetely try Django sometime.
I guess I'll do it when I have a real need to do some serious web
stuff.

As for TurboGears, I'm not very impressed...
This is a pile of different components picked by someone according to
his liking, very well glued together. Althouh its quality may be good,
why should I stick with a number of components chosen according the
criteria of some other guy?
For example, why kid instead of Cheetah? Why CherryPy?
Really, it isn't that hard to install cheetah and, if you want an
object relational mapper, sqlobject. Once you have them, using raw
mod_python is just a pleasure.
I feel I'm in front of a white clean canvas and I just start coding.
I like the flexibility of being able to choose each part of "my own
framework".
I even created a small script that does the automatic crud stuff for me
(not as polished as Django for sure, but it works like a charm).

Anyway, there's still an issue with using these frameworks:
Availability. It's very hard, if not impossible, to find a decent web
host at an affordable price. Although I guess many of those who use
Django, for example, run their own host.
Being able to use raw mod_python gives you an advantage here.

Luis
 
G

Gerhard Fiedler

You say that you haven't tried Django or any other Python framework.
Perhaps you should. You seem to have at least the start of the right
idea about web application organization, so I think you'd be pleasantly
surprised with what you'll find already done for you by the major Python
frameworks and how much time you'll stop wasting on code that isn't part
of your application.

I've checked it out quickly, and it seems that it is not possible to
install e.g. TurboGears on a typical shared host -- as a normal user. You
seem to run a shared hosts farm (IIRC). What's your point of view of
hosting TurboGears or Django on a shared host? Is that (reasonably)
possible?

Thanks,
Gerhard
 
C

Cliff Wells

I've checked it out quickly, and it seems that it is not possible to
install e.g. TurboGears on a typical shared host -- as a normal user. You
seem to run a shared hosts farm (IIRC). What's your point of view of
hosting TurboGears or Django on a shared host? Is that (reasonably)
possible?

There's quite a few actually:

http://www.turbogears.org/preview/docs/deployment/hosting.html

That's just a few picks Kevin made, there are many more. As I
understand it textdrive also supports TG.

For myself, I handle user-installation of TurboGears pretty much like I
do all user-installed Python packages: using setuptools. Any user who
uses easy_install or 'python setup.py install' gets their packages
automatically installed into a subdirectory of their home directory and
that takes precedence over the system installed packages. Works like a
charm.

Regards,
Cliff

--
 
C

Cliff Wells

Well... yes, you're right.
I guess that the reason for not having used a framework already is
laziness...

Trust me, I'm quite familiar with the laziness problem =)
I have experience with Karrigell, which rocks too, but it lacks some
deployment options (no mod_python, no fastcgi, etc).

And as far as I could see in the Django docs, I should learn many new
things to do exactly the same, such as yet another templating language
or how to map urls with regular expressions (I still couldn't wrap my
head around regex... I find them very boring to learn...). But you are
absolutely right. I should definetely try Django sometime.
I guess I'll do it when I have a real need to do some serious web
stuff.

As for TurboGears, I'm not very impressed...
This is a pile of different components picked by someone according to
his liking, very well glued together. Althouh its quality may be good,
why should I stick with a number of components chosen according the
criteria of some other guy?
For example, why kid instead of Cheetah? Why CherryPy?
Really, it isn't that hard to install cheetah and, if you want an
object relational mapper, sqlobject. Once you have them, using raw
mod_python is just a pleasure.

Agreed. But on the other hand, it isn't always about having "the best"
of each (why didn't they use Twisted rather than CherryPy would be *my*
question), but rather having a complete development stack that's
pre-integrated and is *good enough*. And mind you, the integration work
is quite substantial. Also, TurboGears has definitely proven the "a
rising tide lifts all boats" maxim, TurboGears has marketing and
community and all the projects that comprise TurboGears have benefited
from it.

Ultimately a framework is about helping you get *your* job done. If
your job is assembling frameworks or evaluating which ORM is best, then
that's no help ;-) But I suspect those people are in the minority and
most people just want to get their sites done without trying to figure
out which is "best" and then trying to figure out how to integrate that
with other components.

Also, TurboGears supports template plugins (I wrote one to support
Nevow's Stan, and there is a Cheetah plugin as well), and work is being
done to support alternate ORMs (SQLAlchemy is working now, although not
all the TG addons support it yet). The goal is to at least offer people
the opportunity to replace certain components in the framework if they
object to some part of TG. That's not the *ultimate* goal, but Kevin is
a pragmatic guy and recognizes that component bias can hurt TurboGears'
adoption and so is trying to address that in some fashion.
I feel I'm in front of a white clean canvas and I just start coding.
I like the flexibility of being able to choose each part of "my own
framework".
I even created a small script that does the automatic crud stuff for me
(not as polished as Django for sure, but it works like a charm).

Sure, and if you are doing it as a hobby, or to learn or to perhaps take
over the world with a new ORM, then that's great. But if someone is
paying you by the hour to develop a website for them and you are writing
an ORM when there's already half dozen out there, then someone probably
isn't getting their money's worth. This is the problem frameworks were
meant to address: putting your focus back on your web application rather
than all the details that go into it. Do you lose some flexibility?
You bet. Not a lot, but a noticeable amount. Of course the flip side
is that you can turn out a pretty sophisticated web app *by yourself* in
a few days.

I saw DHH of Ruby on Rails fame at FOSCON last year and he really
impressed me with is no-nonsense philosophy about web frameworks. His
approach is the antithesis of Zope, Joomla, et al. Django and TurboGears
are no-nonsense in the same vein: they aren't about providing every
feature under the sun or blazing performance or ultimate
configurability. They are about eliminating the time-consuming details
that you face every time you start a project.
Anyway, there's still an issue with using these frameworks:
Availability. It's very hard, if not impossible, to find a decent web
host at an affordable price. Although I guess many of those who use
Django, for example, run their own host.

Not true. As I posted elsewhere there are many hosts who will run
frameworks (I suspect the pressure of Ruby on Rails really pushed open
the door). Here's a short list from the TurboGears site:
http://www.turbogears.org/preview/docs/deployment/hosting.html

And from the Django site:
http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts

WebFaction (formerly python-hosting) even has a control panel that will
install the framework of your choice with a mouse-click.



Regards,
Cliff

--
 
C

Cameron Laird

Just spoke with my department and looks like we still want to go with a
server scripting method. Although MVC may be better fit, for the sake
of the learning curve, we want to use a PSP style method.
.
.
.
I'll explicitly reinforce what others have mentioned already:
MVC, PSP, and server-side scripting don't partition solution
space in the way your description suggests. You can use an
MVC model, and implement on the server-side, for example.

I'm not arguing with your decision, which I suspect I don't
understand; I just don't want you excluding combinations that
turn out to be mutually compatible.
 
C

Conrad

I may be a bit biased, but I would not run a web server under Windows...

That's not biased - that's just good sense. When I started in
this business, there was a saying "Nobody ever got fired for
recommending IBM" - even though there were sometimes better
solutions, IBM was the politically safe choice. Windows has now
filled that niche, sadly. BSD is a hard sell in many shops,
and it has nothing to do with it's merits, which are considerable.
When you consider that you can build a BSD server with the
kernel stripped down to exactly the pieces you need, and load
only the packages you need, when you consider that the BSDs have
dominated the netcraft uptimes charts, one wonders just what
process is gone through to EVER select a Windows server platform.
I want, no, I demand a server to be secure, stable and efficient.
On all three criteria, Windows loses hands-down.

Have you considered Postgresql instead ?

Ditto - I don't mind MySQL for serving up fairly static content,
but when the transactions get a bit more rough and tumble, I've
been very satisfied with PostgreSQL.
 
C

Conrad

A few years ago I did some research, and the result was that while
PostgreSQL was claimed to have more features and a better design, the
reports of database corruption seemed to have been more frequent than with
MySQL. The usual reason given was that MySQL was more mature.

I assume you don't agree... :)

Gerhard

Maturity is an interesting word. The PostgreSQL pedigree
reaches back about thirty years, which in some peoples minds,
would constitute a degree of maturity. While I can't claim to
have done your extensive (and well documented) research, I can
say that I was a happy MySQL user a couple of years ago, using
it to quickly serve up fairly static content. Happy, that is,
until I put it into a more dynamic order entry/processing
environment. I started finding glitches - orphaned records -
one table totally corrupted. I found I was spending more and
more time coding to make sure the transactions completed, and
less time developing new code. I switched that client to
PostgreSQL and have had ZERO problems since. Many of the
"features" that MySQL is only now adding are playing catchup
to core data integrity values that PostgreSQL has had for much
longer, so it could be argued that in some areas, MySQL can
be said to be much less "mature".
 
G

Gerhard Fiedler

I can't claim to have done your extensive (and well documented) research,

You maybe should consider new reading glasses. Or learn how to respond to
the correct message. Either you somehow got it all completely wrong, or you
responded to the wrong message.

Or is there something in PostgreSQL that makes its users acidic? :)

Gerhard
 
C

Conrad

You maybe should consider new reading glasses. Or learn how to respond to
the correct message. Either you somehow got it all completely wrong, or
you responded to the wrong message.

Or is there something in PostgreSQL that makes its users acidic? :)

Gerhard

Well, maybe so -

I followed up to this message:
Subject: Re: Using Python for my web site
From: Gerhard Fiedler <[email protected]>
Newsgroups: comp.lang.python
Date: Mon, 31 Jul 2006 17:12:56 -0300

Which begins "A few years ago" and is signed Gerhard. It appears
that Bruno and Sybren did the same, no? Perhaps we could get a
referal for all of us to an optician for group rates?

Here's my issue - someone, who according to my defective newsreader
and clearly myopic eyes appeared to be you, once again invoked the
word research. Not only research, but results. I've done research.
It's a rigorous pain in the kiester, and it's seldom as black and
white as you hoped it would be going into the project. But due to
the blood I've donated to a couple of research projects, I would
hope that the words "research" and "results" carried some honest
syntactic weight. In other words, if I've done research, I would
hope it involved more than reading a couple of Linux Journal
articles, and a blog posting by some kid who's been serving up
pictures of his sister's kitties with MySQL for two years now with
no problems.

I haven't seen any significant research on PosgreSQL vs. MySQL
in an apples-to-apples, detached, no-axes-to-grind study. I
have seen a number of "tastes great" "less filling" studies.
I have seen MySQL bite me on the butt, more than once, and I'm
deeply attached to my butt, however anectdotal that may be.

But I'll have the honesty to not claim it's "research". Just
hands-on experience with a tool.

And no, PostgeSQL admins didn't get acidic using PostgreSQL,
which is proven to be calming, regrow hair, whiten your teeth
and improve stamina (it really does - I've done research on it).

We got that way from dealing with other DBs before we switched.

Cheers,

Conrad
 
S

Sybren Stuvel

Conrad enlightened us with:
[...] one wonders just what process is gone through to EVER select a
Windows server platform.

"I know it, and I don't know all the other platforms, therefore
Windows will have to be used". I think most of the reasoning goes like
that. I suspect that most times, though, there isn't even a choice for
a Windows system - they don't know any other system, for them
"computer" is a synonym for "Windows".

Sybren
 
G

Gerhard Fiedler

Which begins "A few years ago"

Exactly. Isn't this a good start for honesty? It doesn't claim to state
anything up to date.

It continues "I did some research", "some" being a very clear indicator
that I didn't consider this a thorough research. From the stated results of
this research it should be clear to any reasonable reader what kind of
research that was. "Claimed to have", "seemed to have" are not really
expressions that try to claim more than they are.

What does it mean to you when someone says "reports seemed to have been"?
Is that what you call "extensive (and well documented) research"? If so,
your standards don't really seem to be what you seem to say they are.

It appears that Bruno and Sybren did the same, no?

No. Neither Bruno nor Sybren got defensive or resorted to sarcasm.
Perhaps we could get a referal for all of us to an optician for group
rates?

Or for a few therapy sessions. There's no need to get defensive, just
because someone spent a day a few years ago reading documentation,
searching the web and newsgroups for experiences that people have with both
databases (like you and Cliff), got at that time the impression that what
those people reported (anecdotically -- that's all one can get without tons
of time and money to spend) was what I wrote it was, and stated this. I did
not overstate any of that, nor did I make it less subjective than it was.

So what's your problem? Why the sarcasm? "A blog posting by some kid who's
been serving up pictures of his sister's kitties with MySQL" -- again the
same sarcasm. Having a bad week?
Here's my issue - someone, who according to my defective newsreader and
clearly myopic eyes appeared to be you, once again invoked the word
research. Not only research, but results. I've done research.

Read the context. I didn't use the "r" word without context. You may not
like the word in that (very "light") context, but that's a personal issue,
and I couldn't really foresee it. The context was pretty clear, at least
for someone with a minimum of goodwill, wasn't it?
I haven't seen any significant research on PosgreSQL vs. MySQL in an
apples-to-apples, detached, no-axes-to-grind study.

Neither have I. I would have been glad to read it, at the time I needed to
decide between the two. So yes, it's all anectodical "evidence" (or is that
also too strong a word?). Hunting for that is the only form of research
someone like me (not a database admin, but in the need of selecting
databases for projects) can afford. I thought that was kind of understood.


BTW, compared to a lot of "research" that has the only function of
providing a paper to further the career of someone and "prove" some
preconceived notions, my (admittedly very light) research was done with
honesty, without predisposition towards any results and with the desire to
actually get results. I just spent on it what I could afford. That may not
be enough for everybody else's standards, but that's how I (and many
others) need to operate.

Maybe I could have used a more appropriate word. I just don't know one;
"research" was the closest I came up with.

Gerhard
 
B

Bruno Desthuilliers

Conrad a écrit :
That's not biased

Well, actually, yes it is. Definitively.
<troll>
To make a long story short, my opinion is that the only sensible thing
to do with Windows is to wipe it out and install an OS instead. OTHO,
there are surely strong objective reasons for *not* using Windows - I
just don't feel like wasting my time finding them !-)
</troll>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top