>
> There should be no benefit to moving them to multiple model files. It 
> would have the same performance (or perhaps slower).
>
> The models file is processed on every page load, so it can get expensive 
> if you have a lot of tables defined in it.
> I'm sure Bruno can chime in here, but here is his recipe for model-less 
> apps...
>
> http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py
>  
>

I've mentioned this before -- note that Bruno's "model-less" approach is 
also heavily class-based. There's nothing wrong with that, but it's worth 
noting that you do not have to take such a class-based approach when moving 
your model definitions to modules. You can simply create one or more 
functions in your modules and move all of your db.define_table calls to 
those functions, just as you would in a standard model file.

Likewise, you could also use Bruno's class-based approach even in standard 
model files. In fact, you might get some of the speed benefits of the 
module approach even with standard model files by moving define_table calls 
into classes or functions within the model file, and only calling them (and 
therefore actually defining the tables) when needed in the controller 
(i.e., lazy table definitions).

You should also be aware of conditional model execution, as described in 
the second set of bullets here: 
http://web2py.com/books/default/chapter/29/4#Workflow.

Anthony

-- 



Reply via email to