Skip to content

Instantly share code, notes, and snippets.

@dplepage
Created November 27, 2012 19:11
Show Gist options
  • Save dplepage/4156332 to your computer and use it in GitHub Desktop.
Save dplepage/4156332 to your computer and use it in GitHub Desktop.
Put an editor URL in Werkzeug's debugger pages
This quick hack wraps the filenames in the Werkzeug debugger with a link that opens them in my editor.
In my particular case I have Sublime Text and SublHandler on OS X (urls below), so my links point to subl://open/?url=<file url>, but you can easily change this for any other URL handler.
Sublime Text: http://www.sublimetext.com/
SublHandler (for OS X): https://github.com/asuth/subl-handler
import werkzeug.debug.tbtools as tbt
tbt.FRAME_HTML = u'''\
<div class="frame" id="frame-%(id)d">
<h4>
File
<a href="subl://open/?url=file://%(filename)s&line=%(lineno)s">
<cite class="filename">"%(filename)s"</cite></a>,
line <em class="line">%(lineno)s</em>,
in <code class="function">%(function_name)s</code></h4>
<pre>%(current_line)s</pre>
</div>
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment