debug – Parerga und Paralipomena http://www.michelepasin.org/blog At the core of all well-founded belief lies belief that is unfounded - Wittgenstein Mon, 24 May 2010 10:46:53 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.11 13825966 Django debug toolbar http://www.michelepasin.org/blog/2010/05/24/django-debug-toolbar/ http://www.michelepasin.org/blog/2010/05/24/django-debug-toolbar/#comments Mon, 24 May 2010 10:46:53 +0000 http://www.michelepasin.org/blog/?p=690

Django Debug Toolbar 0.8 from Idan Gazit on Vimeo.

This is just an amazingly useful application you might want to add to your django development tools.

Installation is a breeze:


$ easy_install django-debug-toolbar

Then you need to add some parameters to your settings.py, as explained here.
It’s likely that you don’t want the debug-toolbar to show on your production site as well, but only where you’re doing development. So a more portable alternative to the usual way to add the debug-toolbar parameters is the following:


# set to True if you're on the production server
LIVESERVER = False

# ..... other settings....

if not LIVESERVER:
	# stuff for the debug toolbar
	INSTALLED_APPS += 	('debug_toolbar',)
	INTERNAL_IPS = ('127.0.0.1',)
	MIDDLEWARE_CLASSES += ( 'debug_toolbar.middleware.DebugToolbarMiddleware', )

The LIVESERVER variable is the only thing you’ve got to manually change when copying your code to the production server…

]]>
http://www.michelepasin.org/blog/2010/05/24/django-debug-toolbar/feed/ 1 690
Python debugging and Textmate http://www.michelepasin.org/blog/2010/02/12/python-debugging-and-textmate/ Fri, 12 Feb 2010 13:23:29 +0000 http://magicrebirth.wordpress.com/?p=546 I’ve never realized that among the many things Textmate does well there’s also python debugging. Well, to be precise Textmate doesn’t do much as it just relies on python’s default debugger, called PDB. Ok, probably PDB isn’t the cutting edge debugger you’re looking for, but it’s worth a try imho.

Nothing to install in order to try: just open up a python script with textmate, hit cmd+shift+D and a debug-terminal window will open. The essential commands for Pdb are (the first letter is the one to digit):

  • s(tep): Execute the current line, stop at the first possible occasion (either in a function that is called or on the next line in the current function).
  • r(eturn): Continue execution until the current subroutine returns.
  • n(ext): Continue execution until the next line in the current function is reached or it returns.
  • p(rint) expression: Evaluate the expression in the current context and print its value.
  • a(rgs): Print the argument list of the current function.
  • q(uit): Quit from the debugger
  • c(ont(inue)): Instead of quitting, Continue execution, only stop when a breakpoint is encountered.
  • A nice and clear crash course of Pbd can also be found here.

    OTHER TEXTMATE TIPS AND TRICKS:

  • PdbTextMateSupport is a plugin that gives you a more powerful debugger within Textmate: a detailed description of its (simple) installation is here.
  • a nice post about 10 cool TextMate tips: most of them are HTML/CSS related, but worth checking out!
  • Textmate basic tutorial. This is a must for everyone who wants to use TextMate seriously (available also in Japanese!)
  • Three plugins that’ll make textmate shine even more: Project Plus (adds extra functionalities to the project drawer), GetBundles (a better version of the old GetBundle), Ack In Project (a much faster ‘search in project’ function).
  • Nice screencast on how to use the Math bundle
  • ]]>
    546