Author: russellm
Date: 2007-05-29 06:09:24 -0500 (Tue, 29 May 2007)
New Revision: 5379

Modified:
   django/trunk/django/conf/global_settings.py
   django/trunk/django/core/context_processors.py
   django/trunk/docs/settings.txt
   django/trunk/docs/templates_python.txt
Log:
Fixed #1278 -- Added a context processor that puts MEDIA_URL in the context, 
and added that context processor to the default set. Thanks to Ubernostrum for 
the patch.


Modified: django/trunk/django/conf/global_settings.py
===================================================================
--- django/trunk/django/conf/global_settings.py 2007-05-29 10:20:10 UTC (rev 
5378)
+++ django/trunk/django/conf/global_settings.py 2007-05-29 11:09:24 UTC (rev 
5379)
@@ -144,6 +144,7 @@
     'django.core.context_processors.auth',
     'django.core.context_processors.debug',
     'django.core.context_processors.i18n',
+    'django.core.context_processors.media',
 #    'django.core.context_processors.request',
 )
 

Modified: django/trunk/django/core/context_processors.py
===================================================================
--- django/trunk/django/core/context_processors.py      2007-05-29 10:20:10 UTC 
(rev 5378)
+++ django/trunk/django/core/context_processors.py      2007-05-29 11:09:24 UTC 
(rev 5379)
@@ -42,6 +42,13 @@
 
     return context_extras
 
+def media(request):
+    """
+    Adds media-related context variables to the context.
+
+    """
+    return {'MEDIA_URL': settings.MEDIA_URL}
+
 def request(request):
     return {'request': request}
 

Modified: django/trunk/docs/settings.txt
===================================================================
--- django/trunk/docs/settings.txt      2007-05-29 10:20:10 UTC (rev 5378)
+++ django/trunk/docs/settings.txt      2007-05-29 11:09:24 UTC (rev 5379)
@@ -776,7 +776,8 @@
 
     ("django.core.context_processors.auth",
     "django.core.context_processors.debug",
-    "django.core.context_processors.i18n")
+    "django.core.context_processors.i18n",
+    "django.core.context_processors.media")
 
 A tuple of callables that are used to populate the context in 
``RequestContext``.
 These callables take a request object as their argument and return a dictionary

Modified: django/trunk/docs/templates_python.txt
===================================================================
--- django/trunk/docs/templates_python.txt      2007-05-29 10:20:10 UTC (rev 
5378)
+++ django/trunk/docs/templates_python.txt      2007-05-29 11:09:24 UTC (rev 
5379)
@@ -294,7 +294,8 @@
 
     ("django.core.context_processors.auth",
     "django.core.context_processors.debug",
-    "django.core.context_processors.i18n")
+    "django.core.context_processors.i18n",
+    "django.core.context_processors.media")
 
 Each processor is applied in order. That means, if one processor adds a
 variable to the context and a second processor adds a variable with the same
@@ -390,6 +391,15 @@
 .. _LANGUAGE_CODE setting: ../settings/#language-code
 .. _internationalization docs: ../i18n/
 
+django.core.context_processors.media
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processors, every
+``RequestContext`` will contain ``MEDIA_URL``,  providing the 
+value of the `MEDIA_URL setting`_.
+
+.. _MEDIA_URL setting: ../settings/#media-url
+
 django.core.context_processors.request
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 


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

Reply via email to