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

Controller functions can return:

  • a string: return "Hello" and this would be the body of the returned page
  • a dictionary return dict(message="Hello") and this would be passed to a view
  • streaming data return'filename','rb')) to return a large file
  • a set of xmlrpc exposed methods `return response.xmlrpc(request,methods)``

Often you just return a dictionary containing a definition of those variables you want to pass to the view. By default a function() in will be rendered by a view called controller/function.html. If this view is not found the generic.html view renders the variables in the dictionary. A controller function can also return a string. In this case the view is not executed and the string is returned instead.

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