"Open file in Textmate"-support in werkzeug debugger browser view

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))

try:
  from werkzeug.debug import tbtools
  from werkzeug.utils import escape
  tbtools.FRAME_HTML = u'''\
  <div class="frame" id="frame-%(id)d">
    <h4>File <a style="color:%(projectfile)s;" href="txmt://open/?url=file://%(filename)s&line=%(lineno)s" class="filename">%(filename)s</a>,
        line <em class="line">%(lineno)s</em>,
        in <code class="function">%(function_name)s</code></h4>
    <pre>%(current_line)s</pre>
  </div>
  '''
  
  def myrender(self):
    return tbtools.FRAME_HTML % {
      'id':       self.id,
      'projectfile':    'firebrick' if self.filename.find(PROJECT_DIR) == 0 else 'inherit',
      'filename':     escape(self.filename),
      'lineno':     self.lineno,
      'function_name':  escape(self.function_name),
      'current_line':   escape(self.current_line.strip())
    }
  
  tbtools.Frame.render = myrender
  
except ImportError:
  pass

More like this

  1. Interactive debugger and other Paste niceties by maxua 3 years, 8 months ago
  2. DebugFooter middleware with textmate links by crucialfelix 4 years, 8 months ago
  3. DebugMiddleware footer with links to quick open file/line# in TextMate on local machine by felix_the_third 3 years, 4 months ago
  4. models ColorField with clean minimal widget by andybak 2 years ago
  5. EditingMiddleware (quickly open views and templates in your text editor!) by johnboxall 3 years, 11 months ago

Comments

(Forgotten your password?)