these functions are support functions lifted from the django_debug toolbar and couchdebugpanel code.