def _make_response(content, content_type, status, file_name=None):
    """
    Custom response function that is called by pyexcel-webio
    """
    response = HttpResponse(content, content_type=content_type, status=status)
    if file_name:
        if PY2_VERSION and isinstance(file_name, unicode):
            file_name = file_name.encode('utf-8')
        url_encoded_file_name = urllib_quote(file_name)
        response["Content-Disposition"] = (
            "attachment; filename=%s;filename*=utf-8''%s" %
            (url_encoded_file_name, url_encoded_file_name))
    return response


webio.init_webio(_make_response)

from pyexcel_webio import (  # noqa
    make_response, make_response_from_array, make_response_from_dict,
    make_response_from_records, make_response_from_book_dict,
    make_response_from_query_sets)


def make_response_from_a_table(model,
                               file_type,
                               status=200,
                               file_name=None,
                               **keywords):
    """
    Produce a single sheet Excel book of *file_type*
Exemple #2
0
def includeme(config):
    """ pyramid_excel extension
    """
    webio.init_webio(_make_response)
    config.set_request_factory(ExcelRequestFactory)
Exemple #3
0
def init_excel(app):
    app.request_class = ExcelRequest
    webio.init_webio(_make_response)
    return app
Exemple #4
0
def includeme(config):
    """ pyramid_excel extension
    """
    webio.init_webio(_make_response)
    config.set_request_factory(ExcelRequestFactory)