On 1/12/07, Christopher Arndt <[EMAIL PROTECTED]> wrote:
>
> You should use 'tg_include_widgets' and then you could use JS/CSS with widgets
> again too.
>

That's fine, if you want the JS/CSS and to show up on *every page* of
your site.  If you ended up with a lot of JS heavy widgets your page
load times will suffer and I don't think it's the best way of doing
it.


> Both both solutions, yours and mine, are only useful for widgets that appear 
> on
> every page, aren't they? Or do you have special logic in your variable
> providers to include only specific widgets on a per-request basis?
>

More or less.  Since widgets are designed so one instance of each
widget is used throughout the site, all adding the instances to the
variable providers is doing is making that particular namespace
available in the view, instead of making the widget available to the
view via the controller's returned data.  The downside of this is that
the widgets don't get "scanned" so their JS/CSS counterparts are
injected into the template header automatically.

Your method makes all of the widgets available to the view on every
page view and, IIRC, the JS and CSS will be injected into the template
header for every widget in `tg.include_widgets`.

Your way gives more bulky page loads but is more automatic, my way I
have to add the JS/CSS manually to each particular view, but is more
streamlined as you won't get JS/CSS included that's not being used.

As I say, I believe that a new mechanism for adding widgets is
required to separate the MVC a little more.  Otherwise one would have
to create two versions of the same method if you wish to use a widget.
 One with the widget in the return value and one without.  Not very
DRY.


-- 
Lee McFadden

blog: http://www.splee.co.uk
work: http://fireflisystems.com
skype: fireflisystems

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