cool. note that include_widgets doesn't need to be set site wide either.
[/some/path] include_widgets = ... On 7/21/07, Brian Beck <[EMAIL PROTECTED]> wrote: > > Hey folks, > > Just wanted to share a little recipe we use all over the place in > Pagoda[1]. > > http://paste.turbogears.org/paste/1521 > > It's a decorator you add *after* expose that will include widgets in > the resulting context so that TurboGears will automatically include > their JavaScript and CSS in the output page. Kinda like the > include_widgets config option, but not site-wide -- mostly useful for > CSS and JavaScript. One advantage over just including the widgets in > the output of your method is that you can list the widgets as strings > (no imports necessary) and it'll use turbogears.util.load_class to > import them for you. Another is that it unclutters your method and > context of trivial things like widget setup. > > Examples: > > class PagodaAdmin(RootController): > @expose(template="pagoda.templates.admin_edit") > @include_widgets('pagoda.widgets.admin.edit_base') > def edit(self): > return dict(message="Hey!") > > Now the edit_base widget and all its dependencies will be included in > the page (if you have the master template that looks at tg_js and all > that). You can also pass more than one, include instances instead of > strings, and if you care about access to the context variable, give it > a different name: > > from pagoda.widgets.admin import control_panel_css > > @expose(template="pagoda.templates.control_panel") > @include_widgets('pagoda.widgets.admin.base', control_panel_css, > context_var='widgets') > def control_panel(self): > return dict(message="Get your widgets here!") > > > Enjoy: http://paste.turbogears.org/paste/1521 > > > [1] http://www.pagodacms.org > > > > > -- cheers elvelind grandin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

