Some of the information here may be outdated, please check the book instead
[edit]

We use to teach introductory programming courses by covering in the order loops, conditionals, function calls and classes. networking and web development are considered advanced topics. Here I am proposing an alternate model based on the fact that students already have familiarity with the user interface of web applications, their workflow, and the basic networking concepts associated to the internet. Moreover I believe that MVC is more important than OOP.

Lesson 1: Function calls

1) download web2py, start it, create an app called Test

2) in controller default write

def hello: return "hello world"

Lesson learned: when you visit a US a function is called, the function produces an output

Lesson 2: Parameter passing

3) in controller default write

def hello: return "hello "+request.vars.name

and call it with: http://127.0.0.1:8000/Test/default/hello?name=Massimo

4) in controller default write

def add(a,b): return a+b
def hello: return "hello a+b="+str(add(request.vars.a,request.vars.b))

and call it with: http://127.0.0.1:8000/Test/default/hello?a=3?b=6

Lesson learned: when you call a function a function you can pass parameters as input

Lesson 3: Conditionals

5) in controller default write

def hello:
   if request.vars.name: return "hello "+request.vars.name
   else: return "hello whoever you are"

Lesson learned: if...else

work in progress...

© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.