I'm not sure if this has been discussed.  My searches yielded no fruit.

I have page components that are common across many of my pages.  Here
are a few of them:

  == A user specific menu, cached in the session.
  == A shopping cart, cached in the session.
  == A list of recently visited items, cached in the session.

My current approach to making these objects available to a template is
to have a 'base_dict(request)' function that returns a dictionary
containing the common things under well known names (e.g., { 'menu':
menu, 'cart': cart, 'recent_items': recent_items}).

For each view which returns a response (not a redirect), I do:

d = base_dict(request)
d['item'] = selected_item
# etc
return render_to_response('item.html', d)


The idea is to set up the base dictionary in the same way in
anticipation of each page having the same common components.

Is this something that other people find themselves doing?  What is
your comfort level with this approach versus a more independent
component approach?  In Django that might mean a template block which
knows how to load it's own data (a la a Tiles controller?).

I'm not arguing the merits of either, I'm just trying to guage whether
my approach is common or whether there is a better way that I'm not
aware of.

Thanks!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to