Пример #1
0
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))
Пример #2
0
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)
Пример #3
0
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
Пример #4
0
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,
                                          })
Пример #5
0
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)
Пример #6
0
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)
Пример #7
0
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})
Пример #8
0
def view(request):
    universe = getuniverse()
    return render_to_response("/fancy_base/two_columns/view.mako", {"universe": universe}, RequestContext(request))