Commits

Anonymous committed cdb5b52

RequestContext integration

Comments (0)

Files changed (2)

gadmin/models/gpage.py

 from google.appengine.ext.db import polymodel
 from gadmin.types import get_types
 from django.shortcuts import render_to_response
-from django.template import TemplateDoesNotExist
+from django.template import TemplateDoesNotExist, RequestContext
 from django.core.urlresolvers import reverse
 # TODO: check all posible 'more than 1000' cases
 # TODO: profile and cache get_*
     def has_prev(self):
         return (not self.get_prev())
 
-    def get_response(self):
+    def get_response(self, request):
         data = {
             'current': self,
             'breadcrumb': get_breadcrumb(self)
         }
         tname = 'gsite/types/%s.html' % self.class_name().lower()
         try:
-            return render_to_response(tname, data)
+            return render_to_response(tname, data,
+                    context_instance=RequestContext(request))
         except TemplateDoesNotExist:
-            return render_to_response('gsite/gpage.html', data)
+            return render_to_response('gsite/gpage.html', data,
+                    context_instance=RequestContext(request))
         return None
 
     def get_link_target(self):
 from gadmin.account import admin_required
 from google.appengine.ext.db import djangoforms
 from google.appengine.api import urlfetch, users
+from django.template import RequestContext
 from django.conf import settings
 
+def gadmin_render(request, template_name, data):
+    return render_to_response(template_name, data,
+            context_instance=RequestContext(request))
+
 @admin_required
 def index(request, form=None):
     data = {'tree': gpage.get_all(),}
-    return render_to_response('gadmin/index.html', data)
+    return gadmin_render(request, 'gadmin/index.html', data)
 
 @admin_required
 def new(request, form=None):
     if not form:
         form = GPageForm()
     data = {'page_form': form}
-    return render_to_response('gadmin/new.html', data)
+    return gadmin_render(request, 'gadmin/new.html', data)
 
 @admin_required
 def add(request):
             setattr(page, k, v)
         page.put()
     data = { 'page': page, 'form': form, 'cform': cform }
-    return render_to_response('gadmin/edit.html', data)
+    return gadmin_render(request, 'gadmin/edit.html', data)
 
 @admin_required
 def reorder(request):
         form = GTypeForm(initial={'type': page.class_name})
 
     data = {'page': page, 'form': form}
-    return render_to_response('gadmin/type.html', data)
+    return gadmin_render(request, 'gadmin/type.html', data)
 
 def site(request, slug=""):
     page = gpage.get_by_slug(slug)
     if not page: raise Http404()
 
-    return page.get_response()
+    return page.get_response(request)