Re: [Tutor] python web documentation ( without frameworks?)

2008-06-25 Thread Alan Gauld


"Kent Johnson" <[EMAIL PROTECTED]> wrote


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.


I'd go so far as to say that its a good idea to write ONE web app
using CGI just to get a feel for it and to understand howmuch (or 
little)

a framework gives you. But to use CGI as your normal web tool would
be a bit like using assembler when you could use C or using C
when you could use python... Its possible but just a lot more work.

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python web documentation ( without frameworks?)

2008-06-25 Thread Kent Johnson
On Wed, Jun 25, 2008 at 6:47 PM, Patrick <[EMAIL PROTECTED]> 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.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python web documentation ( without frameworks?)

2008-06-25 Thread Patrick

Thanks guys for responding to my post.

I did buy a book on turbogears today and I am watching some screencasts 
as well, I don't want to be ignorant of frameworks.


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.


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.


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?


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?


Am I the only one who wants an end-to-end understanding of my web app? 
Am I crazy? I am feeling a bit alienated here-Patrick



ALAN GAULD wrote:

Forwarding to list.
Please use Reply All when reponding to posts.

- Forwarded Message 
From: Jeff Johnson <[EMAIL PROTECTED]>
To: Alan Gauld <[EMAIL PROTECTED]>
Sent: Wednesday, 25 June, 2008 9:51:33 PM
Subject: Re: [Tutor] python web documentation ( without frameworks?)

This was crazy.  The presenter at our Python user group last night left 
everything at home.  So he proceeded to borrow someone's laptop, 
download and install Python and web.py (http://webpy.org/) and we all 
went through building the demo which displayed records in an SQLite 
table and allowed you to add one and redisplay.  I have used Django and 
web.py works pretty much the same way using templates and all, but 
web.py is significantly "lighter".


You might want to install web.py and go through the demo.  Put it in a 
folder called "deleteme" and you can just delete the folder if you're 
not interested.


Alan Gauld wrote:
  

"Patrick" <[EMAIL PROTECTED]> wrote


cherrypy, django and turbogears but for some reason I just don't want 
to use a framework. Are there any current books you could recommend 
for general python web programming? Most of the general web 
programming books seem to be from 2004 or before.
  

There's a good reason for that! Vanilla CGI - the most basic web
programming mechanism available is a rsource hog, non scaleable
and very hard to maintain beyiond small trivial projects. So people
have moved to Frameworks which offer better performance,
easier implementation and far better maintainablility. All Frameworks
aim to achieve that, the choice is pretty much a personal prefernce.

The good news is that if you want to continuously reinvent the wheel
by using vanilla CGI the books from 2004 will all pretty much still work.
CGI hasn't changed much and neither have the core web modules in
Python.

HTH,



  


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python web documentation ( without frameworks?)

2008-06-25 Thread Alan Gauld


"Patrick" <[EMAIL PROTECTED]> wrote

cherrypy, django and turbogears but for some reason I just don't 
want to use a framework. Are there any current books you could 
recommend for general python web programming? Most of the general 
web programming books seem to be from 2004 or before.


There's a good reason for that! Vanilla CGI - the most basic web
programming mechanism available is a rsource hog, non scaleable
and very hard to maintain beyiond small trivial projects. So people
have moved to Frameworks which offer better performance,
easier implementation and far better maintainablility. All Frameworks
aim to achieve that, the choice is pretty much a personal prefernce.

The good news is that if you want to continuously reinvent the wheel
by using vanilla CGI the books from 2004 will all pretty much still 
work.

CGI hasn't changed much and neither have the core web modules in
Python.

HTH,



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python web documentation ( without frameworks?)

2008-06-25 Thread Kent Johnson
On Tue, Jun 24, 2008 at 11:00 PM, Patrick <[EMAIL PROTECTED]> wrote:
> Hi Everyone
>
> This is my first post here. I would like to switch from php/mysql to
> python(mod_python) and postgresql. There are several recent books on
> cherrypy, django and turbogears but for some reason I just don't want to use
> a framework. Are there any current books you could recommend for general
> python web programming? Most of the general web programming books seem to be
> from 2004 or before.

If you don't want to use a framework that pretty much limits you to
plain CGI or mod_python handlers. They don't provide much so there is
not much documentation. At this level of programming I don't think
much has changed since 2004. The cgi module docs are one place to
start:
http://docs.python.org/lib/module-cgi.html

Foundations of Network Programming covers many different aspects of
network programming including a chapter on CGI:
http://www.apress.com/book/view/1590593715

My guess is that, coming from php, you will find this level of web
programming to be pretty primitive and you will soon be looking at the
frameworks or at least a templating package.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor