Am 08.02.2011 um 11:24 schrieb Christoph Zwerschke:
Am 08.02.2011 07:11 schrieb Nate:
Thanks Christoph and NiL. For now I just created the table and form
instance in the main controller. Is that wrong? You said its in the
V, but shouldn't it be in the C? By instantiate I mean
autoField = AutoCompleteField(
No, widgets belong in TG's interpretation of MVC more to the view
than to the controller. They don't "do" much except rendering.
Actually they are just another form of templating and packaging
things together, i.e. they play a similar role as page templates do
which are considered the view in TG (btw, some other web frameworks
have a different notion of views so don't get confused by that).
They are just *used* by the controllers, but they should not be
considered part of it.
I disagree. The distinction between view and controller in TG (and
every other webframework for that matter) is superficial. If I have to
set up the view as detailed as I have to in an action (giving the
template, passing widget instances into template contexts, computing
auxilliary values) it's a foolish consistency IMHO to insist on
instantiating widgets somewhere else.
It is certainly a virtue to have to open and read as few source files
as possible to understand a given functionality. So, if possible,
everything is in one controler file in my projects.
If it grows to large, I split it up into controller.py, forms/
widgets.py parallel to each other. But the *instances* of the widgets,
in case of forms for example with the action as parameter, *always* go
into the controller.
Of course if I create widgets that are of greater usability, I move
these into a dedicated widgets-module.
Diez
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.