Django debug with vim and vdebug
You can also be interested in:
I'm currently re-configuring all my vim stuff, operation which I perform every x months/years. I used to debug django application using pdb
and its set_trace
method, this time I decided to integrate a debugging tool inside vim as I always did for PHP using xdebug.
I decided (after some other attempts), to use vdebug, which (as described in the project page):
it interfaces with any debugger that faithfully uses the DBGP protocol
This is nice, because it can be used to debug PHP with xdebug but also other programming languages, like python.
After installing the plugin you can type in vim :VdebugSetUpPython for instructions, and you'll be told to download the dbgb library from here: http://code.activestate.com/komodo/remotedebugging/, then the author wrote some patches for the client.py module in order to correct an error thrown when using eval inside the debugger.
I like to work with virtualenv and I prefer to install packages with pip, so I changed a bit the procedure to have all these stuff up and running (my patch works for dbgp version 1.1):
- install dbgp inside virtualenv
$ pip install dbgp==1.1
- apply my patch for the 1.1 version
$ patch /path/to/virtualenv/lib/python2.7/site-packages/dbgp/client.py < client.patch
- Then where you want to stop the execution:
import dbgp.client dbgp.client.brk(host="localhost", port=9000)
- Press F5 inside vim, reload the page, return to vim and wait for the debugger to start
Now you should be able to use eval (F12) inside vim to eval expressions.
I know that patching a third-party module is not a good idea, but this is a module used for debug purposes, it shouldn't play a role in production, and even if something gets broken due to a module update, problems should come up only when running the debug tool.
Here I post the patch code used:
Your Smartwatch Loves Tasker!
Your Smartwatch Loves Tasker!
Featured
Archive
- 2021
- 2020
- 2019
- 2018
- 2017
- Nov
- Oct
- Aug
- Jun
- Mar
- Feb
- 2016
- Oct
- Jun
- May
- Apr
- Mar
- Feb
- Jan
- 2015
- Nov
- Oct
- Aug
- Apr
- Mar
- Feb
- Jan
- 2014
- Sep
- Jul
- May
- Apr
- Mar
- Feb
- Jan
- 2013
- Nov
- Oct
- Sep
- Aug
- Jul
- Jun
- May
- Apr
- Mar
- Feb
- Jan
- 2012
- Dec
- Nov
- Oct
- Aug
- Jul
- Jun
- May
- Apr
- Jan
- 2011
- Dec
- Nov
- Oct
- Sep
- Aug
- Jul
- Jun
- May