<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: SimpleBlog Part 4 - Widgets</title>
	<atom:link href="http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/</link>
	<description>Bring out the g33k</description>
	<pubDate>Thu, 20 Nov 2008 18:32:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Andre</title>
		<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-33758</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Thu, 20 Sep 2007 07:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-33758</guid>
		<description>Very nice tutorial. Thanks. Hope to see more coming - if you find the time.

I just started with TG and wonder whether there is something special you wanted to tell about self-reference, as promised at the end of part 3, that I could not figure out (most probably).</description>
		<content:encoded><![CDATA[<p>Very nice tutorial. Thanks. Hope to see more coming - if you find the time.</p>
<p>I just started with TG and wonder whether there is something special you wanted to tell about self-reference, as promised at the end of part 3, that I could not figure out (most probably).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alberto Valverde</title>
		<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-23523</link>
		<dc:creator>Alberto Valverde</dc:creator>
		<pubDate>Thu, 07 Dec 2006 13:30:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-23523</guid>
		<description>@splee


I'm not sure my message got through as I intended it... 

It's not a solution to include *Links and *Sources in templates, but a solution to make sure that widgets that we really need in every template to be treated in the same way as if they were returned in the dict controllers return, that is, their resources automatically included so the widget behaves as intended.

For example, I have an app. where master.html (using genshi) includes a search form widget that shows up in every page. That search form needs to include an async.js link (it shows results asyncronously in the main div) and autocomplete.js (it autocomplete's results a  là AutoCompleteField).

If I just dump this widget in variable_providers it's required resources won't be included because the code in turbogears.controlles._process_output that picks up widget's resources from the dict that the controller returns doesn't see those variables (as they're sent directly to the template engine plugin).

I agree that it should be used with care as we don't want unneeded links included in every page, but sometimes this is what we need.

It's a solution for the problem mentioned in http://trac.turbogears.org/turbogears/ticket/847 
(which I'm about to close ;)

Regards,
Alberto</description>
		<content:encoded><![CDATA[<p>@splee</p>
<p>I&#8217;m not sure my message got through as I intended it&#8230; </p>
<p>It&#8217;s not a solution to include *Links and *Sources in templates, but a solution to make sure that widgets that we really need in every template to be treated in the same way as if they were returned in the dict controllers return, that is, their resources automatically included so the widget behaves as intended.</p>
<p>For example, I have an app. where master.html (using genshi) includes a search form widget that shows up in every page. That search form needs to include an async.js link (it shows results asyncronously in the main div) and autocomplete.js (it autocomplete&#8217;s results a  là AutoCompleteField).</p>
<p>If I just dump this widget in variable<em>providers it&#8217;s required resources won&#8217;t be included because the code in turbogears.controlles.</em>process_output that picks up widget&#8217;s resources from the dict that the controller returns doesn&#8217;t see those variables (as they&#8217;re sent directly to the template engine plugin).</p>
<p>I agree that it should be used with care as we don&#8217;t want unneeded links included in every page, but sometimes this is what we need.</p>
<p>It&#8217;s a solution for the problem mentioned in <a href="http://trac.turbogears.org/turbogears/ticket/847" rel="nofollow">http://trac.turbogears.org/turbogears/ticket/847</a><br />
(which I&#8217;m about to close ;)</p>
<p>Regards,<br />
Alberto</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Splee</title>
		<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-23266</link>
		<dc:creator>Splee</dc:creator>
		<pubDate>Tue, 05 Dec 2006 14:04:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-23266</guid>
		<description>@Alberto:  That's something that I've not come across yet as all my AJAX stuff is currently done without widgets.

I didn't think about using the `tg.include_widgets` config option, but I don't particularly like it as a solution to getting JSLink/JSSource or CSSLink/CSSSource widgets to show up in the templates - if you have a lot of widgets that could end up being a *lot* of code that is inserted on every page view.

It might be an idea to have a conversation about this on the mailing list with regards to ToscaWidgets to see if there's any way around this potential issue.</description>
		<content:encoded><![CDATA[<p>@Alberto:  That&#8217;s something that I&#8217;ve not come across yet as all my AJAX stuff is currently done without widgets.</p>
<p>I didn&#8217;t think about using the <code>tg.include_widgets</code> config option, but I don&#8217;t particularly like it as a solution to getting JSLink/JSSource or CSSLink/CSSSource widgets to show up in the templates - if you have a lot of widgets that could end up being a <em>lot</em> of code that is inserted on every page view.</p>
<p>It might be an idea to have a conversation about this on the mailing list with regards to ToscaWidgets to see if there&#8217;s any way around this potential issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alberto Valverde</title>
		<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-22437</link>
		<dc:creator>Alberto Valverde</dc:creator>
		<pubDate>Thu, 30 Nov 2006 20:20:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-22437</guid>
		<description>Nice article! 

I just wanted to comment Lee's comment a couple of lines back... The best way to  have widgets available at every template is to list them in the `tg.include_widgets` config variable. 

For two reasons: 

1) Any JS and CSS needed by widgets listed there will get included in the template too (doesn\'t happen with `variable_providers`, unfortunately)

2) You can control the order in which those resources are included (only in the 1.0 branch in Subversion, ATM, 1.0b2 will include it). This doesn\'t happen when you dump widgets in the dict returned by the controller because iterating it doesn\'t guarantee any ordering and could be the cause (has bitten in the past) of some mysterious bugs. For example, if mochikit gets included after a JSSource that needs it.

Widgets listed at `tg.include_all` will appear in the template as `tg_${widget_name}`. For example, `myapp.widgets.show_user` will be `tg_show_user` in the template.</description>
		<content:encoded><![CDATA[<p>Nice article! </p>
<p>I just wanted to comment Lee&#8217;s comment a couple of lines back&#8230; The best way to  have widgets available at every template is to list them in the <code>tg.include_widgets</code> config variable. </p>
<p>For two reasons: </p>
<p>1) Any JS and CSS needed by widgets listed there will get included in the template too (doesn\&#8217;t happen with <code>variable_providers</code>, unfortunately)</p>
<p>2) You can control the order in which those resources are included (only in the 1.0 branch in Subversion, ATM, 1.0b2 will include it). This doesn\&#8217;t happen when you dump widgets in the dict returned by the controller because iterating it doesn\&#8217;t guarantee any ordering and could be the cause (has bitten in the past) of some mysterious bugs. For example, if mochikit gets included after a JSSource that needs it.</p>
<p>Widgets listed at <code>tg.include_all</code> will appear in the template as <code>tg_${widget_name}</code>. For example, <code>myapp.widgets.show_user</code> will be <code>tg_show_user</code> in the template.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dax</title>
		<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-22159</link>
		<dc:creator>dax</dc:creator>
		<pubDate>Wed, 29 Nov 2006 16:51:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-22159</guid>
		<description>Just wondering, where is the best place to put the code for ProviderObj to achieve MVC? Should this also be on the widgets.py?

Your tutorial is way coool! Learned a lot. Thanks a lot! :)</description>
		<content:encoded><![CDATA[<p>Just wondering, where is the best place to put the code for ProviderObj to achieve MVC? Should this also be on the widgets.py?</p>
<p>Your tutorial is way coool! Learned a lot. Thanks a lot! :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Splee</title>
		<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-21896</link>
		<dc:creator>Splee</dc:creator>
		<pubDate>Tue, 28 Nov 2006 21:34:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-21896</guid>
		<description>@Matthew: Fixed.  Thanks again for your feedback.</description>
		<content:encoded><![CDATA[<p>@Matthew: Fixed.  Thanks again for your feedback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Webber</title>
		<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-21824</link>
		<dc:creator>Matthew Webber</dc:creator>
		<pubDate>Tue, 28 Nov 2006 16:00:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-21824</guid>
		<description>Thanks for all your excellent work on this series, much appreciated.

Part 4 needs one change, where it says to Open the new, blank file, post_display_template.kid, the name should be post_display_widget.kid.

Also, on your web site the "simpleblog" category is missing part 2 (tag missing I guess).</description>
		<content:encoded><![CDATA[<p>Thanks for all your excellent work on this series, much appreciated.</p>
<p>Part 4 needs one change, where it says to Open the new, blank file, post<em>display</em>template.kid, the name should be post<em>display</em>widget.kid.</p>
<p>Also, on your web site the &#8220;simpleblog&#8221; category is missing part 2 (tag missing I guess).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graham Higgins</title>
		<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-19810</link>
		<dc:creator>Graham Higgins</dc:creator>
		<pubDate>Wed, 22 Nov 2006 00:44:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-19810</guid>
		<description>This is a /really/ nice walkthrough. Your effort is much appreciated.</description>
		<content:encoded><![CDATA[<p>This is a /really/ nice walkthrough. Your effort is much appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Splee</title>
		<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-19326</link>
		<dc:creator>Splee</dc:creator>
		<pubDate>Mon, 20 Nov 2006 19:20:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-19326</guid>
		<description>@Joseph:  Excellent point, and it is something I will bring up later in the series in detail.

For anyone who doesn't want to wait, I generally create a simple object, adding each widget as an attribute.  I then add this object to TurboGears' variable providers:

    from turbogears import view

    class ProviderObj(object):
        def __init__(self, *args, **kw):
            for k,v in kw.iteritems():
                setattr(self, k, v)
                
    append_providers(vars):
        vars["mywidgets"] = ProviderObj(widget_name=widget_instance,
                                        another_widget=another_widget_instance)
    view.variable_providers.append(append_providers)

This means that I can then access every widget from the template via `${tg.mywidgets.widget_name}` or `${tg.mywidgets.another_widget}`.

This preserves the designed use of widgets (i.e. one widget shared between all of the apps threads) and the MVC paradigm.</description>
		<content:encoded><![CDATA[<p>@Joseph:  Excellent point, and it is something I will bring up later in the series in detail.</p>
<p>For anyone who doesn&#8217;t want to wait, I generally create a simple object, adding each widget as an attribute.  I then add this object to TurboGears&#8217; variable providers:</p>
<pre><code>from turbogears import view

class ProviderObj(object):
    def __init__(self, *args, **kw):
        for k,v in kw.iteritems():
            setattr(self, k, v)

append_providers(vars):
    vars["mywidgets"] = ProviderObj(widget_name=widget_instance,
                                    another_widget=another_widget_instance)
view.variable_providers.append(append_providers)
</code></pre>
<p>This means that I can then access every widget from the template via <code>${tg.mywidgets.widget_name}</code> or <code>${tg.mywidgets.another_widget}</code>.</p>
<p>This preserves the designed use of widgets (i.e. one widget shared between all of the apps threads) and the MVC paradigm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Tate</title>
		<link>http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-19255</link>
		<dc:creator>Joseph Tate</dc:creator>
		<pubDate>Mon, 20 Nov 2006 13:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.splee.co.uk/2006/11/19/simpleblog-part-4-widgets/#comment-19255</guid>
		<description>It should be noted that the use of widgets in this tutorial breaks the Model/View/Controller paradigm.  The controller method is tied to an HTML view.  The widget cannot be dumped as json or xmlrpc.  If this isn't important to you, then use it as described, if it is, the instantiation of the widget can be done directly in the template, rather than returned by the controller.

Otherwise a great tutorial.

jtate</description>
		<content:encoded><![CDATA[<p>It should be noted that the use of widgets in this tutorial breaks the Model/View/Controller paradigm.  The controller method is tied to an HTML view.  The widget cannot be dumped as json or xmlrpc.  If this isn&#8217;t important to you, then use it as described, if it is, the instantiation of the widget can be done directly in the template, rather than returned by the controller.</p>
<p>Otherwise a great tutorial.</p>
<p>jtate</p>
]]></content:encoded>
	</item>
</channel>
</rss>
