What is we have folders like models/__init__.py models/default/__init__.py models/default/index.py
and __init__ is executed for every action and controller and default/__init__ is executed for every action in controller default.py and default/index only for the index action, etc etc. if there is no folder, then controllers are executed alphabetically (but __init__ skips ahead if present). other depencies in models would result in a mess. What d you think? On Jun 11, 4:39 pm, AchipA <attila.cs...@gmail.com> wrote: > On Jun 11, 10:08 pm, DenesL <denes1...@yahoo.ca> wrote: > > > Using the common code in the controller as a model substitute? > > There goes the MVC separation. > > And the other models still get executed. > > > I think AchipA means execute one model only. > > The problem is that models are executed before controllers (aren't > > they?), but then this points back to using ifs in models as suggested > > by Massimo. > > Not quite. I recommend we do the same as we do with views. E.g. if I'm > in a stuff.py controller, then > a) if there is no stuff.py in models, we include all models, > convenient for development, friendly to newbies > b) if there IS a stuff.py in models, we include ONLY that, and that > model file is responsible for it's dependencies - see below. > > > Let's suppose we change that. > > Where do you keep common model code? > > common = used by all ctls, except those with a name > > Now, for the kicker - in the model we could do an equivalent of > {{extend 'layout.html'}} (=sort of import ?) to include any > dependencies. This would also pull in any 'common' models (just like > we do with layout.html). Note the subtle difference - I don't want a > single EXTRA model to be included - I want to avoid loading > unnecessary models. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---