Well, for the widgets, why not pass something like this out of your controller:

return {'pagefield': pagefieldval, 'pagefield2': pagefieldval2,
'widgetvals': { 'widgetval': widgetval, 'widgetval2': widgetval2}}

Then, in your template, when you call the render method on the widget,
you simply pass in the dict for the widget. Since you can build up the
dict over the course of running your controller code, you don't even
have to have a long and ugly return statement, you just return a dict
variable that you've been building. The code becomes neater, and
solves that portion of the problem.

Now, in the end, what I got out of the links you provided was this:
Why are all widgets stateless? Because the time has not been spent to
make them stateful.

Aside from that, it's just purely an aesthetic, and one that I happen
to agree with. Widgets, to me, shouldn't have to have state. They draw
a limited piece of the page. They provide CSS. They provide
Javascript. For me, having them have members that are related to the
current request seems wrong. Purely aesthetic, I know.

On Wed, Feb 2, 2011 at 2:16 AM, Kalium <[email protected]> wrote:
> Sorry if this is a dead horse that's being resurrected, I just got
> thinking about it though.
>
> I've read this in regards to stateless widgets
>
> http://docs.turbogears.org/1.0/StatelessWidgets
> http://groups.google.com/group/turbogears/tree/browse_frm/thread/74926e779c1da137/0189b1618e09b9c4
>
> Whilst I can understand the use of using widgets in a stateless
> manner, none of the arguments seem to really
> give me a good reason why not to create various instances of the same
> widget (apart from the validate decorator issue). The other reasons
> are a bit wishy washy and somewhat dogmatic (no offence intended).
>
> One of the reasons I don't always rely on stateless widgets is that
> sometimes I may be wanting to use a large number of variable
> attributes(I'm talking about 20+ perhaps) for the one widget.
> This means that each time I return from my controller with the widget
> I have to pass all those variables as well.
> I find it easier (both to code and to read) to create the instance
> with all the vars in the controller, then simply return the widget,
> rather that to return the slew of vars as well and then account for
> them in the template where the display() is called.
>
> Am I a bad person for thinking about widgets in this manner? Are there
> other caveats I am missing?
>
> --
> 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.
>
>



-- 
Michael J. Pedersen
My IM IDs: Jabber/[email protected], ICQ/103345809, AIM/pedermj022171
          Yahoo/pedermj2002, MSN/[email protected]

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