Commits

tehfink committed bcf64e9

initial commit

Comments (0)

Files changed (4)

+syntax: regexp
+\.pyc$
+^media/
+^fabfile
+^nbproject/
+^ref/
+
+syntax: glob
+*.textClipping
+.DS_Store
+project.xml
+*.db
+*.psd
+~*
+*backup
+*svn
+PRE-ALPHA
+
+Name: cms-context_processors
+Description: for django-cms. defines various context processors for inclusion in apps attached to django-cms pages; initially created because because 'sites' was not being passed to photologue template contexts for some reason
+
+Download: http://bitbucket.org/tehfink/cms-context_processors/
+
+Requirements:
+- django-cms-2.0: rev 63a124cfda6c10b9f4831da0627a9f80b64e675c
+- django: 1.1
+
+Last tested with:
+- django-cms-2.0: rev 63a124cfda6c10b9f4831da0627a9f80b64e675c
+- django: rev 11600
+
+Setup
+- make sure requirements are installed and properly working
+- add cms_context_processors to python path
+- add "cms_context_processors.context_processors.XXX" to INSTALLED_APPS, where XXX is the processor you want (at the moment there is only one: 'sites')
+- reference context processor in views/contexts as necessary
+
+Todo:
+- add more context processors!
+
+
+Examples:
+
+TEMPLATE_CONTEXT_PROCESSORS = (
+    �
+    "cms_context_processors.context_processors.site",
+)
+
+
+Note:
+This is not great code, but it works. Please tell me how to make it better!

cms_context_processors/__init__.py

Empty file added.

cms_context_processors/context_processors.py

+from django.contrib.sites.models import Site
+
+
+#def current_site(request):
+def site(request):
+    """
+    A context processor to add the "current site" to the current Context
+    """
+    from django.contrib.sites.models import Site
+    try:
+        current_site = Site.objects.get_current()
+        return {
+            'site': current_site,
+        }
+    except Site.DoesNotExist:
+        # always return a dict
+        return {'current_site':''} # an empty string