On Tue, Feb 10, 2009 at 9:50 AM, Christoph Zwerschke <[email protected]> wrote: > > Sergei Beilin schrieb: >> and another newbie question. I noticed that I can pass data to the >> template engine in two ways: assign smthng to pylons.c.whatever or >> return dict(whatever=whatever). As seen in some examples, sometimes >> both widgets and their data are passed via pylons.c, sometimes the >> widgets via pylons.c and data in dict, and sometimes both via the >> returning dict. >> >> What method should I choose and (most important) why? > > Hi Sergei, I just asked the same question on tg-trunk. It seems (correct > me if I'm wrong) you can do it as you like, but it's best practice to > pass data via the return dict and widgets via the template context > (tg.tmpl_context is an alias for pylons.c if you don't want to import > pylons directly). The reason is that if you use the same controller for > returning json, you only want the data returned. Widgets cannot be > jsonificated and are of no interest in this case anyway.
Yes, that is exactly the case. Another way of looking at it is that. the returned dict is everything that is required for a proper view to render, the tmpl_context is everything optional. The json example is probably the best. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

