On May 1, 2007, at 7:26 AM, kerinin wrote:
>
> my problem is that i would prefer to pass my widgets in a dictionary
> to keep the number of arguments being passed to the template down, so
> instead of passing
>
> return dict(widget1=widget1,
> widget2=widget2,widget3=widget3,widget1data=widget1data,widget2data=wi
> dget2data,widget3data=widget3data)
>
> I would prefer to do this:
>
> return dict(widgets=widgets,data=data)
>
> Unfortunately if a widget needs to insert a JS or CSS link, the link
> doesn't get inserted unless the widget itself is one of the arguments
> being passed to the template. I'm sure there's a better way to do
> this - maybe by inserting the JS/CSS link when widgets are displayed,
> or at least by searching dictionaries lists and tuples to see if they
> contain widgets.
Recursing deep into everything thrown into the output dict could be
too expensive IMO (eg: could potentially consume a SelectResult's
iterator with 10000 records from the db)
> maybe a reserved parameter like
> 'tg_has_nested_widgets' or something could be defined.
The code that searchs the output dict for widgets [1] checks for the
presence of any of two methods and calls them to retrieve resources,
you could make an object like this to store widgets and send them to
the the template:
from turbogears.util import setlike
class WidgetContainer(list):
def retrieve_css(self):
all_css = []
for w in self:
all_css.add_all(w.retrieve_css())
return all_css
def retrieve_javascript(self):
# something similar but taking into
# account that js needs to be categorized by location
# check [1] for details
Alberto
[1] http://tinyurl.com/ys2dxw
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---