AlterEgo
old web2py blog
Useful Links
List all entries
Book
Interactive Examples
F.A.Q.
Free Applications
Plugins
Recipes
Demo of Admin Interface
Semantic web extension
Some of the information here may be outdated, please check the book instead
Edit page
Title:
Security Code:
Body:
(use
this
wiki markup)
We really like web.py 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 web.py code into web2py code. This is an example of web.py 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__": web.run(urls, globals()) which we could translate in web2py as ### in routes.py (optional) routes_in=(('/.*','/myapp/default/hello'),) ### in controller default.py def hello(): return dict(times=request.vars.times or 1,name=request.vars.name or 'world') ### in view default/hello.py {{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.