- Author:
- grandfatha
- Posted:
- February 21, 2012
- Language:
- Python
- Version:
- 1.3
- Score:
- 1 (after 1 ratings)
1) Install django-extensions (requires werkzeug) 2) Paste snippet into settings.py 3) manage.py runserver_plus
Now you should be able to open files in textmate by clicking the file links in the werkzeug error pages. It will also take you to the correct line number and highlight files that are in your project directory in a different color.
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
- find even number by Rajeev529 1 month, 1 week ago
- Form field with fixed value by roam 1 month, 4 weeks ago
- New Snippet! by Antoliny0919 2 months, 1 week ago
- Add Toggle Switch Widget to Django Forms by OgliariNatan 4 months, 3 weeks ago
- get_object_or_none by azwdevops 8 months, 2 weeks ago
Comments
Please login first before commenting.