Overview of features
Home
Read this first
About
web2py is 100% free
Download
Start learning web2py today
Documentation
Authors and contributors
Staff
Affiliated companies
Support
Edit page
Title:
Security Code:
Body:
(use
this
wiki markup)
**Question** This how i understand the relationship: I create a controller: def index(): return dict(mylist = [1,2,3]) then i ihave to create a view with the same name i.e app/views/controller/index.html in which i refer to the server variable list What about if i want to use the same controller index for an other view say my_app/an_other_index.html Can this be done or i have to create an other controller an_other_index and copy exactly the same code from the controller index() My question is can the data computed in one controller used by many views? **Answer** Yes. Examples: def index(): return dict(mylist=[1,2,3]) def other(): return index() index will be rendered by app/views/controller/index.html and other by app/views/controller/other.html. You can also have them share a view: def yet_other(): response.view=request.controller+'/index.html' return index() and yet another will use index as controller and index.html as view.