def change(request): CHANGE_CMD_TEMPLATE = "write_entity {id}:{datalen}:{data}" global_id = request.POST["global_id"] writedata = request.POST["writedata"] command = CHANGE_CMD_TEMPLATE.format(id=global_id, datalen=len(writedata), data=writedata) response = connect(command) return render_to_response("/fancy_base/two_columns/response.mako", {"response": response}, RequestContext(request))
def getuniverse(): response = connect("dump_pickle") if not response.startswith("SUCCESS: dumping pickle\n"): return render_to_response( "/fancy_base/two_columns/response.mako", {"response": response}, RequestContext(request) ) pickledata = response[len("SUCCESS: dumping pickle\n") :] return cpickle.loads(pickledata)
def view_all(request): universe = getuniverse() # return HttpResponse(repr(universe)) try: return render_to_response( "/fancy_base/one_column/view_all.mako", {"universe": universe}, RequestContext(request) ) except: import traceback traceback.print_exc() raise
def edit_page (request): '''Looks for the page that matches the request's path and displays it''' path='/'.join(request.path.split('/')[1:]) try: p=Page.objects.get(name=path) f=PageForm(p) except: p=None f=PageForm() return render_to_response('editor.html',{ 'page': p, 'form': f, })
def render_template(request, template, context = {}): c = RequestContext(request) c.update(context) ext = os.path.splitext(template)[1] template_types = getattr(settings, 'TEMPLATE_TYPES', {}) if not template_types: template_types = {'.mko':'mako'} t = '' for k, v in template_types.items(): if k.lower() == ext.lower(): t = v break if t.lower() == 'mako': from mako_django import render_to_response else: from django.shortcuts import render_to_response return render_to_response(template, context_instance=c)
def render_template(request, template, context={}): c = RequestContext(request) c.update(context) ext = os.path.splitext(template)[1] template_types = getattr(settings, 'TEMPLATE_TYPES', {}) if not template_types: template_types = {'.mko': 'mako'} t = '' for k, v in template_types.items(): if k.lower() == ext.lower(): t = v break if t.lower() == 'mako': from mako_django import render_to_response else: from django.shortcuts import render_to_response return render_to_response(template, context_instance=c)
def view_page (request): '''Looks for the page that matches the request's path and displays it''' path=request.path get_object_or_404(Page,name=request.path) return render_to_response('viewer.html',{ 'page': p})
def view(request): universe = getuniverse() return render_to_response("/fancy_base/two_columns/view.mako", {"universe": universe}, RequestContext(request))