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

We really like but web2py has nothing to do with it. Really. The name is similar by accident.

They are very very different beasts although you can translate code into web2py code.

This is an example of code (not us)

import web

urls = (
  '/(.*)', 'hello'

class hello:        
    def GET(self, name):
        i = web.input(times=1)
        if not name: name = 'world'
        for c in range(int(i.times)):
            print 'Hello,', name+'!'

if __name__ == "__main__":, globals())

which we could translate in web2py as

### in (optional)

### in controller
def hello():
    return dict(times=request.vars.times or 1, or 'world')

### in view default/
{{extend 'layout.html'}}
{{for i in range(int(times)):}}Hello, {{=name}}!{{pass}}

Although we would never write code like this where input is not validated! web2py has objects/helpers to build secure validated forms.

© 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.