Killer Web Development

by Marco Laspe

3.3 How all this stuff works

You might wonder what web2py is actually doing with our controllers, functions and models. web2py is using a dispatching mechanism to translate an url. By convention web2py presumes some things from an url. A typical web2py url has the form

http://hostname/application/controller/function/args?vars

for our pitch app this means:

http://127.0.0.1:8000/pitch/default/entry_post

where

  • pitch = application
  • default = controller
  • entry_post = function

web2py now searches for an application called pitch; if it finds the pitch app it opens a controller default; if the controller default is found it then it calls the function entry_post.

The entry_post function then interacts with the model and the view to create the webpage and then returns the response to the browser (Rember the MVC in section 1.3).

args and vars are not used in our example. The could be things like the id of a user. We will user them later in the book.

The drawing shows this process schematicly:

URL dipatching web2py


Books often read by web2py and Python experts:

Comments

Leave a Reply

Required fields are marked *.