This is the kind of thing I have been wondering about: what is going on under 
the hood?

I was simply doing what the manual told me to do - even if I wasn't sure what 
it 
wanted. The manual needs to be updated. 



________________________________
From: pbreit <pbreitenb...@gmail.com>
To: web2py@googlegroups.com
Cc: Hal Smith <grownup_...@yahoo.com>
Sent: Wed, March 23, 2011 1:15:01 PM
Subject: Re: Runnning my new app

This is a concept that you have to get a firm grasp of.

There is a file "layout.html" that contains all of the base HTML that you might 
want on every page in your site. It has a templating instruction {{include}} 
which is where each of your individual view files will get inserted.

If you recall the default "index.html" file, you should have seen at the top 
"{{extend 'layout.html'}}". This is what tells web2py to take your index.html 
file and insert it into the layout.html file.

What you also should have seen is in controllers/default.py:

def index():
    """
    example action using the internationalization operator T and flash
    rendered by views/default/index.html or views/generic.html
    """
    return dict(message=T('Hello World'))

When you visit "/welcome/default/index" in your browser, it looks for the app 
"welcome, then "default.py" in your controllers file and then "def index()" in 
default.py. You will see that index() returns a variable "message='Hello 
World'". "message" is sent to the view file views/default/index.html and is 
available like this: {{=message}}. The default index.html file includes some 
other content but you should be able to find {{=message}} in there somewhere. 
Try editing "message" to 'Good bye world'. Or try moving {{=message}} to a 
different position in index.html and see what happens.

Reply via email to