[Tutor] python web documentation ( without frameworks?)

Kent Johnson kent37 at tds.net
Thu Jun 26 01:25:50 CEST 2008

On Wed, Jun 25, 2008 at 6:47 PM, Patrick <optomatic at rogers.com> wrote:

> I don't think anyone could argue that working without a framework is better
> for the majority of people, I can clearly see the value of frameworks.
> However the idea of having a bunch of directories that I don't understand
> does not appeal to me, and learning a framework specific way of working with
> MySql, Postgresql etc rather then their native manner won't help me to
> transfer that knowledge into other areas such as desktop applications or
> other languages such as C.

There are a number of different ways of working with databases in
Python. You can use DB-API which is a fairly simple interface to SQL.
You can use SQLAlchemy to make easier to write the SQL. You can use
SQLAlchemy, SQLObject or other ORMs to hide the SQL pretty thoroughly.
Most of these methods are portable to other Python apps including
desktop apps. None of them are truly portable to other languages
though if you stick with DB-API the SQL knowledge will certainly apply
in other languages.
> I have been working with PHP and I don't really like it. However there is
> tons of code out there that I can copy, paste and modify, I don't need to
> re-invent the wheel, just modify it for my own needs. This does not seem to
> be the case with mod_python code.

mod_python by itself is not too popular IMO.

> Would it be logical for me to take python cgi code and rework it for
> mod_python? The two don't seem that different, am I wrong about this?

I think you could do that. Do you have Python CGI code to start with?

> Kent was saying that working without a framework would be fairly primitive,
> are there features I just can't get without a framework? If so why is this?
> Is a framework not just a collection of off the shelf technologies bundled
> into a slick package? Can I not access the same features without a
> framework?

Python is a general-purpose language, it is not specific to web
programming. It has basic facilities built in for, for example, socket
communication, sending email, http requests, etc. There are many
features you will want in a web app that have to be built on top of
the basic capabilities of the language and standard libs. For example,
- request parsing
- request dispatching
- authentication and authorization
- session management
- object-relational mapping
- etc, etc., just look at the feature lists of any of the existing frameworks.

I don't think you understand how little you get with plain Python. I'm
not dissing Python, but again, it is a general purpose language, it
doesn't provide the same facilities as a single-purpose language like
php. Maybe you should try writing a CGI to see what is available.

TurboGears and Pylons do use off-the-shelf technologies, though they
are still third-party technology. Certainly you can use SQLAlchemy,
Genshi, Routes, etc without TurboGears, or you can write equivalent
features yourself, or you can let someone else help with picking
components and gluing them together.

Not every framework repackages other off-the-shelf components. Django
is just Django, AFAIK so is web.py.

Anyway, it really is your choice. If your needs are simple, or you
want to learn how stuff works, you can use plain CGI or mod_python. If
you will need the features of a framework, you might be better off
starting with a framework.


More information about the Tutor mailing list