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.

Of course, you can also instantiate your widgets in the controller module. But usually there is more to it than in your example, e.g. the AutoCompleteField will not be used standalone, but included in a form widget along with other widgets for form fields, with validator for these field, probably also custom fields and validators created by subclassing from the existing fields or validators, or even your own custom widgets, and these can also have their own inline or external templats. Therefore it's better to move these things out of the controller package so it does not get bloated with the widgets details. The idea of widgets is to package away these details so you can reuse them and both tempaltes and controllers can be kept more concise and focus on the major things.

-- Christoph

--
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.

Reply via email to