Beispiel #1
0
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}
Beispiel #2
0
    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
Beispiel #3
0
    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
Beispiel #4
0
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))
Beispiel #5
0
def view_index(request):
    if request.method == 'POST':
        return dispatch_url(request)
    else:
        return d.render_to_response('index.jinja2')
Beispiel #6
0
def demo_index(request):
    return d.render_to_response('demo/index.jinja2')
Beispiel #7
0
def filters_jinja2(request):
    return d.render_to_response('demo/filter_jinja.jinja2')
Beispiel #8
0
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))
Beispiel #9
0
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))
Beispiel #10
0
def test2(request):
    ctx = {
        'sample_list': range(3),
    }
    return d.render_to_response("test2.jinja", ctx)
Beispiel #11
0
def filters_jinja2(request):
    return d.render_to_response('demo/filter_jinja.jinja2')
Beispiel #12
0
def demo_index(request):
    return d.render_to_response('demo/index.jinja2')
Beispiel #13
0
def view_restful_api(request):
    return d.render_to_response('restful_api.jinja2')
Beispiel #14
0
def index(request):
    return d.render_to_response('index.jinja2')