You can put common controller functionality in the model. This is executed
on each request before the controllers. You can check which controller is
called in request.controller.
On Sunday, 13 May 2012 17:31:22 UTC+1, Yarin wrote:
I've always liked the idea of controllers as classes, allowing
That's what I've already been doing, but making decisions in the model on
which code to run based on the request controller turns into a hot mess of
distributed logic and violates the most basic principles of MVC (Models
knowing about Controllers?)
On Sunday, May 13, 2012 1:58:25 PM UTC-4,
in Java (say for example Java EE 6), you would have your own Classes
hierarchy (as extended as needed), and then you would inject what you need
in your controllers (backing beans)... in web2py you can do exactly the
same. Create your own hierarchy of classes (as extended as needed) and then
just
You can put functions in controller files that any other function in the file
can call.
Sebastian- I already have class hierarchies for my model/module stuff. What
I'm talking about using classes to handle controller logic- assembling
views, controlling access, processing forms, managing redirection, etc -
that stuff belongs in controllers, not modules. But the flat, one
Yarin, I see... I know what you mean... I had a quick glance into
compileapp.py line 555... (I guess that it the right place to look at)...
and it looks like that inheritance is not part of it...
filename = os.path.join(folder, 'controllers/%s.py'
% controller)
I use /models as a script folder and I always try to avoid the use of this.
Controllers are for me only a point of entry, the place where I route and
where I got argumuments and I decide about the template rendering.
All the rest of logic goes in sub modules, handlers, helpers and datamodels.
7 matches
Mail list logo