[web2py] Why multiple controllers, models, and what to do with them?

2011-09-08 Thread Luca
I am new to web2py (I've been using Django), and I am confused about a 
couple of things. 

First, the presence of multiple controllers. 
I am trying to build a main app, called (say) www.example.com. 
So I would like to have something like www.example.com/index.html
But if I use the default.py controller, the URL that is automatically mapped 
is default/index.html, not index.html directly.  How do people typically 
organize their URL schema? 

Second, in the default setup, I see db.py and menu.py.   In db.py it is 
noted that I should really add my table declarations to another model file.  
But, all the logic to decide if web2py is running on appengine or not, etc, 
is all in db.py; if I write my table declarations in another file, do I have 
to cut and paste that logic?  Or how is this supposed to work?  All the 
example in the tutorial just edit db.py. 

Many thanks! --Luca



Re: [web2py] Why multiple controllers, models, and what to do with them?

2011-09-08 Thread Kenneth Lundström
 I am new to web2py (I've been using Django), and I am confused about 
a couple of things.


Welcome to web2py.

 First, the presence of multiple controllers.

Every time a function in the controller is called the whole file is 
compiled. By having smaller controller you get an faster application. If 
I have e.g. five options in mainmenu I create five different controllers.


All .py files in models directory is processed for every request. So you 
can have everything in one file or in 20 files. Files are processed in 
alphabetical order.


I have made four files, 1_db_settings (name of the database, password 
and so on), 2_database (table declarations), 3_functions (if needed I 
create functions that can be used in every controller), 4_meny 
(declaration of the meny).


Hope this helps a bit.


Kenneth
Second, in the default setup, I see db.py and menu.py.   In db.py it 
is noted that I should really add my table declarations to another 
model file.  But, all the logic to decide if web2py is running on 
appengine or not, etc, is all in db.py; if I write my table 
declarations in another file, do I have to cut and paste that logic?  
Or how is this supposed to work?  All the example in the tutorial just 
edit db.py.


Many thanks! --Luca





Re: [web2py] Why multiple controllers, models, and what to do with them?

2011-09-08 Thread Luca
Thank you, this is very helpful indeed. 
Luca