cubicweb/pyramid/debug_source_code.py
author Laurent Peuch <cortex@worlddomination.be>
Thu, 26 Sep 2019 06:27:53 +0200
changeset 12773 3a38f779bed5
parent 12772 a2b8c201727f
child 12774 e6bf15a69ea0
permissions -rw-r--r--
[debug-toolbar/display_source_code/security] add security mechanism to only read whitelisted files Closes #17256791
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12771
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
     1
# copyright 2019 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
     2
#
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
     3
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
     4
#
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
     5
# This file is part of CubicWeb.
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
     6
#
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
     7
# CubicWeb is free software: you can redistribute it and/or modify it under the
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
     8
# terms of the GNU Lesser General Public License as published by the Free
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
     9
# Software Foundation, either version 2.1 of the License, or (at your option)
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    10
# any later version.
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    11
#
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    12
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    13
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    14
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    15
# details.
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    16
#
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    17
# You should have received a copy of the GNU Lesser General Public License along
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    18
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    19
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    20
"""
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    21
Debug view for pyramid debug toolbar and others to help development
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    22
"""
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    23
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    24
import os
12772
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    25
import logging
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    26
import inspect
12771
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    27
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    28
from pyramid.response import Response
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    29
from mako.template import Template
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    30
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    31
from cubicweb.misc.source_highlight import highlight_html, generate_css, has_pygments
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    32
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    33
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    34
DEBUG_DISPLAY_SOURCE_CODE_PATH = '_debug_display_source_code'
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    35
12773
3a38f779bed5 [debug-toolbar/display_source_code/security] add security mechanism to only read whitelisted files
Laurent Peuch <cortex@worlddomination.be>
parents: 12772
diff changeset
    36
FILES_WHITE_LIST = set()
3a38f779bed5 [debug-toolbar/display_source_code/security] add security mechanism to only read whitelisted files
Laurent Peuch <cortex@worlddomination.be>
parents: 12772
diff changeset
    37
12771
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    38
12772
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    39
def source_code_url(object_or_class):
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    40
    if object_or_class is None:
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    41
        return ""
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    42
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    43
    if not inspect.isclass(object_or_class):
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    44
        object_or_class = object_or_class.__class__
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    45
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    46
    try:
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    47
        file_path = inspect.getsourcefile(object_or_class)
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    48
    except TypeError:
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    49
        logging.debug("Error while trying to source code of '%s'" % object_or_class)
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    50
        return ""
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    51
12773
3a38f779bed5 [debug-toolbar/display_source_code/security] add security mechanism to only read whitelisted files
Laurent Peuch <cortex@worlddomination.be>
parents: 12772
diff changeset
    52
    FILES_WHITE_LIST.add(file_path)
3a38f779bed5 [debug-toolbar/display_source_code/security] add security mechanism to only read whitelisted files
Laurent Peuch <cortex@worlddomination.be>
parents: 12772
diff changeset
    53
12772
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    54
    try:
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    55
        source_code, line = inspect.getsourcelines(object_or_class)
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    56
    except OSError:  # when we couldn't read the source code/line
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    57
        return '<a href="../%s?file=%s" target="_blank">&lt;&gt;</a>' % (
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    58
            DEBUG_DISPLAY_SOURCE_CODE_PATH, file_path
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    59
        )
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    60
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    61
    # step back a bit so we have a bit of top padding wen displaying the page
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    62
    # and the highlighted line isn't glued to top of the browser window
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    63
    line_anchor = max(0, line - 10)
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    64
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    65
    return '<a href="../%s?file=%s&line=%s&end=%s#line-%s" target="_blank">&lt;&gt;</a>' % (
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    66
        DEBUG_DISPLAY_SOURCE_CODE_PATH, file_path, line, line + len(source_code), line_anchor
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    67
    )
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    68
a2b8c201727f [debug-toolbar/display_source_code] add helper to render link to source file
Laurent Peuch <cortex@worlddomination.be>
parents: 12771
diff changeset
    69
12771
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    70
def debug_display_source_code(request):
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    71
    """
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    72
    This view display a python source file content for making debugging easier.
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    73
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    74
    It is only activated on debug mode (-D) for pyramid during development.
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    75
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    76
    It will uses pygment if installed to colorize the source code.
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    77
    """
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    78
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    79
    if "file" not in request.params:
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    80
        return Response('Error: you should have end up on this page following a link in the '
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    81
                        'pyramid debug toolbar with the correct parameters.')
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    82
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    83
    source_code_file = request.params["file"]
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    84
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    85
    if not os.path.exists(source_code_file):
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    86
        return Response("Error: file '%s' doesn't exist on the filesystem." % source_code_file)
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    87
12773
3a38f779bed5 [debug-toolbar/display_source_code/security] add security mechanism to only read whitelisted files
Laurent Peuch <cortex@worlddomination.be>
parents: 12772
diff changeset
    88
    # security
3a38f779bed5 [debug-toolbar/display_source_code/security] add security mechanism to only read whitelisted files
Laurent Peuch <cortex@worlddomination.be>
parents: 12772
diff changeset
    89
    if source_code_file not in FILES_WHITE_LIST:
3a38f779bed5 [debug-toolbar/display_source_code/security] add security mechanism to only read whitelisted files
Laurent Peuch <cortex@worlddomination.be>
parents: 12772
diff changeset
    90
        return Response("Error: access to file is not authorized")
3a38f779bed5 [debug-toolbar/display_source_code/security] add security mechanism to only read whitelisted files
Laurent Peuch <cortex@worlddomination.be>
parents: 12772
diff changeset
    91
12771
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    92
    try:
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    93
        content = open(source_code_file, "r").read()
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    94
    except Exception as e:
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    95
        return Response("Error: while opening file '%s' got the error: %s" % (source_code_file, e))
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    96
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    97
    lines = []
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    98
    line_begin = request.params.get("line", None)
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
    99
    if line_begin:
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   100
        line_end = request.params.get("end", line_begin)
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   101
        lines = list(range(int(line_begin), int(line_end) + 1))
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   102
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   103
    this_file_directory = os.path.split(os.path.realpath(__file__))[0]
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   104
    template_filename = os.path.join(this_file_directory,
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   105
                                     "debug_toolbar_templates/debug_source_code.mako")
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   106
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   107
    html = Template(filename=template_filename).render(
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   108
        file_path=source_code_file,
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   109
        content=content,
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   110
        has_pygments=has_pygments,
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   111
        highlight_html=highlight_html,
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   112
        css=generate_css(),
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   113
        lines=lines,
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   114
    )
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   115
70597b447fb7 [debug-toolbar/display_source_code] add a pyramid view that display syntax highlighted python source file
Laurent Peuch <cortex@worlddomination.be>
parents:
diff changeset
   116
    return Response(html)