Author: jtauber
Date: Thu Oct  2 21:02:13 2008
New Revision: 998

Modified:
    trunk/apps/core_apps/friends_app/views.py

Log:
added ability to pass in extra context to friends_objects

Modified: trunk/apps/core_apps/friends_app/views.py
==============================================================================
--- trunk/apps/core_apps/friends_app/views.py   (original)
+++ trunk/apps/core_apps/friends_app/views.py   Thu Oct  2 21:02:13 2008
@@ -94,7 +94,7 @@


  @login_required
-def friends_objects(request, template_name, friends_objects_function):
+def friends_objects(request, template_name, friends_objects_function,  
extra_context={}):
      """
      Display friends' objects.

@@ -102,11 +102,18 @@
      take an iterator over users and return an iterator over objects
      belonging to those users. This iterator over objects is then passed
      to the template of the given name as ``object_list``.
+
+    The template is also passed variable defined in ``extra_context``
+    which should be a dictionary of variable names to functions taking a
+    request object and returning the value for that variable.
      """

      friends = friend_set_for(request.user)
-    object_list = friends_objects_function(friends)

-    return render_to_response(template_name, {
-        "object_list": object_list,
-    }, context_instance=RequestContext(request))
+    dictionary = {
+        "object_list": friends_objects_function(friends),
+    }
+    for name, func in extra_context.items():
+        dictionary[name] = func(request)
+
+    return render_to_response(template_name, dictionary,  
context_instance=RequestContext(request))

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" 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/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to