- 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
- Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
- Help text hyperlinks by sa2812 1 year, 7 months ago
Comments
Please login first before commenting.