def documents(request, userid): if request.method == 'GET': return d.render_to_response("form.html") tgz = request.FILES['tgz'] tf = tarfile.open(fileobj=tgz, mode="r:gz") tf.extractall("/var/www/containers/php%s/" % userid) return {'result': True}
def process_response(self, request, response): if response is d.Http404: return response path = request.path[1:] if path == "favicon.ico" or path.endswith(".png"): return serve(request, path) if path.startswith("theme"): return serve(request, request.path[len("/theme/"):]) if path == "" or path.endswith("/"): path = path + "index.html" if os.path.exists(dotslash(path)) and os.path.isfile(dotslash(path)): return d.render_to_response(path, {}, d.RequestContext(request)) ajax = read_yaml_file(dotslash("ajax.yaml")) if ajax: if request.GET: path = request.path + "?" + request.META["QUERY_STRING"] # TODO: make it immune to order of GET params if path in ajax: return JSONResponse(ajax[path]) if request.path in ajax: return JSONResponse(ajax[request.path]) if not request.path.endswith("/"): return d.HttpResponseRedirect(request.path + "/") return response
def process_response(self, request, response): if response is d.Http404: return response path = request.path[1:] if path == "favicon.ico" or path.endswith(".png"): return serve(request, path) if path.startswith("theme"): return serve(request, request.path[len("/theme/"):]) if path == "" or path.endswith("/"): path = path + "index.html" if os.path.exists(dotslash(path)) and os.path.isfile(dotslash(path)): return d.render_to_response( path, {}, d.RequestContext(request) ) ajax = read_yaml_file(dotslash("ajax.yaml")) if ajax: if request.GET: path = request.path + "?" + request.META["QUERY_STRING"] # TODO: make it immune to order of GET params if path in ajax: return JSONResponse(ajax[path]) if request.path in ajax: return JSONResponse(ajax[request.path]) if not request.path.endswith("/"): return d.HttpResponseRedirect(request.path + "/") return response
def index(request): ctx = { 'random_number': randint(1, 1000), 'random_text1': str(uuid4()), 'random_text2': str(uuid4()), } return d.render_to_response('index.html', ctx, context_instance=d.RequestContext(request))
def view_index(request): if request.method == 'POST': return dispatch_url(request) else: return d.render_to_response('index.jinja2')
def demo_index(request): return d.render_to_response('demo/index.jinja2')
def filters_jinja2(request): return d.render_to_response('demo/filter_jinja.jinja2')
def show_user(request, user_id): context = {'user': d.get_object_or_404(User, pk=user_id), 'usermodel': User} return d.render_to_response('show_user.html', context, context_instance=d.RequestContext(request))
def list_users(request): context = {'users': User.objects.all(), 'usermodel': User} return d.render_to_response('list_users.html', context, context_instance=d.RequestContext(request))
def test2(request): ctx = { 'sample_list': range(3), } return d.render_to_response("test2.jinja", ctx)
def view_restful_api(request): return d.render_to_response('restful_api.jinja2')
def index(request): return d.render_to_response('index.jinja2')