Your SlideShare is downloading. ×
0
DISQUS                         Tools and Stu                           David Cramer                          twitter.com/z...
django-debug-toolbarFriday, July 15, 2011
$ pip install django-debug-toolbar                        # settings.py                        INSTALLED_APPS = (         ...
Friday, July 15, 2011
Friday, July 15, 2011
Friday, July 15, 2011
Friday, July 15, 2011
Extending the Toolbar                        class SettingsVarsDebugPanel(DebugPanel):                            """     ...
Extending the Toolbar                        	   DEBUG_TOOLBAR_PANELS = (                        	       debug_toolbar.pan...
Werkzeug                        w/ django-devserverFriday, July 15, 2011
$ pip install django-devserver                        # settings.py                        INSTALLED_APPS = (             ...
Friday, July 15, 2011
Friday, July 15, 2011
•     SQL Queries (Realtime and Summarized)                  •     Profiling (Execution time, Memory Usage)                ...
class AjaxDumpModule(DevServerModule):                            """                            Dumps the content of all ...
Extending the Toolbar                        	   DEVSERVER_MODULES = (                                 devserver.modules.s...
SentryFriday, July 15, 2011
$ pip install django-sentry                        # settings.py                        INSTALLED_APPS = (                ...
Friday, July 15, 2011
Friday, July 15, 2011
# settings.py                        MIDDLEWARE_CLASSES = (                          sentry.client.middleware.SentryRespon...
Friday, July 15, 2011
•     Builtin support for Celery                  •     Server/Client (clients can be any language)                  •    ...
GargoyleFriday, July 15, 2011
$ pip install gargoyle                        # settings.py                        INSTALLED_APPS = (                     ...
Friday, July 15, 2011
from gargoyle import gargoyle                        def my_view(request):                            if gargoyle.is_activ...
class HostConditionSet(ConditionSet):                            hostname = String()                            def can_ex...
Friday, July 15, 2011
Wrap UpFriday, July 15, 2011
DISQUS                          Questions?                          psst, we’re hiring                         jobs@disqus...
References                  •     Debug Toolbar                        https://github.com/django-debug-toolbar/django-debu...
Upcoming SlideShare
Loading in...5
×

Tools for Development and Debugging in Python

2,463

Published on

Published in: Technology
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,463
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
69
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide

Transcript of "Tools for Development and Debugging in Python"

  1. 1. DISQUS Tools and Stu David Cramer twitter.com/zeegFriday, July 15, 2011
  2. 2. django-debug-toolbarFriday, July 15, 2011
  3. 3. $ pip install django-debug-toolbar # settings.py INSTALLED_APPS = ( debug_toolbar, ) MIDDLEWARE_CLASSES = ( debug_toolbar.middleware.DebugToolbarMiddleware, ) INTERNAL_IPS = (127.0.0.1,)Friday, July 15, 2011
  4. 4. Friday, July 15, 2011
  5. 5. Friday, July 15, 2011
  6. 6. Friday, July 15, 2011
  7. 7. Friday, July 15, 2011
  8. 8. Extending the Toolbar class SettingsVarsDebugPanel(DebugPanel): """ A panel to display all variables in django.conf.settings """ name = SettingsVars has_content = True def nav_title(self): return _(Settings) def title(self): return _(Settings) def content(self): context = self.context.copy() context.update({ settings: get_safe_settings(), }) return as_string(debug_toolbar/panels/settings.html, context)Friday, July 15, 2011
  9. 9. Extending the Toolbar DEBUG_TOOLBAR_PANELS = ( debug_toolbar.panels.version.VersionDebugPanel, debug_toolbar.panels.timer.TimerDebugPanel, debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel, debug_toolbar.panels.headers.HeaderDebugPanel, debug_toolbar.panels.request_vars.RequestVarsDebugPanel, debug_toolbar.panels.template.TemplateDebugPanel, debug_toolbar.panels.sql.SQLDebugPanel, debug_toolbar.panels.signals.SignalDebugPanel, debug_toolbar.panels.logger.LoggingPanel, )Friday, July 15, 2011
  10. 10. Werkzeug w/ django-devserverFriday, July 15, 2011
  11. 11. $ pip install django-devserver # settings.py INSTALLED_APPS = ( devserver, ) $ python manage.py runserverFriday, July 15, 2011
  12. 12. Friday, July 15, 2011
  13. 13. Friday, July 15, 2011
  14. 14. • SQL Queries (Realtime and Summarized) • Profiling (Execution time, Memory Usage) • Cache usage summary • Ajax requests • Session information • Write your own!Friday, July 15, 2011
  15. 15. class AjaxDumpModule(DevServerModule): """ Dumps the content of all AJAX responses. """ logger_name = ajax def process_response(self, request, response): if request.is_ajax(): self.logger.info(response.content)Friday, July 15, 2011
  16. 16. Extending the Toolbar DEVSERVER_MODULES = ( devserver.modules.sql.SQLSummaryModule, devserver.modules.ajax.AjaxDumpModule’, devserver.modules.profile.ProfileSummaryModule, devserver.modules.request.SessionInfoModule, devserver.modules.profile.MemoryUseModule, devserver.modules.profile.LeftOversModule, devserver.modules.cache.CacheSummaryModule, )Friday, July 15, 2011
  17. 17. SentryFriday, July 15, 2011
  18. 18. $ pip install django-sentry # settings.py INSTALLED_APPS = ( sentry, sentry.client, )Friday, July 15, 2011
  19. 19. Friday, July 15, 2011
  20. 20. Friday, July 15, 2011
  21. 21. # settings.py MIDDLEWARE_CLASSES = ( sentry.client.middleware.SentryResponseErrorIdMiddleware, ) # 500.html <p>Sorry friends, something’s not working.</p> {% if request.sentry.id %} <p>If you need assistance, you may reference this error as <strong>{{ request.sentry.id }}</strong>.</p> {% endif %}Friday, July 15, 2011
  22. 22. Friday, July 15, 2011
  23. 23. • Builtin support for Celery • Server/Client (clients can be any language) • 2.x powered by Flask/Redis (no Django)Friday, July 15, 2011
  24. 24. GargoyleFriday, July 15, 2011
  25. 25. $ pip install gargoyle # settings.py INSTALLED_APPS = ( gargoyle, )Friday, July 15, 2011
  26. 26. Friday, July 15, 2011
  27. 27. from gargoyle import gargoyle def my_view(request): if gargoyle.is_active(awesome, request): return new happy version :D else: return old sad version :(Friday, July 15, 2011
  28. 28. class HostConditionSet(ConditionSet): hostname = String() def can_execute(self, instance): return instance is None def get_field_value(self, instance, field_name): if field_name == hostname: return socket.gethostname() gargoyle.register(HostConditionSet())Friday, July 15, 2011
  29. 29. Friday, July 15, 2011
  30. 30. Wrap UpFriday, July 15, 2011
  31. 31. DISQUS Questions? psst, we’re hiring jobs@disqus.comFriday, July 15, 2011
  32. 32. References • Debug Toolbar https://github.com/django-debug-toolbar/django-debug-toolbar • Devserver https://github.com/dcramer/django-devserver • Werkzeug https://github.com/mitsuhiko/werkzeug • Gargoyle https://github.com/disqus/gargoyle • Sentry https://github.com/dcramer/django-sentry (1.x) https://github.com/dcramer/sentry (2.x) code.disqus.comFriday, July 15, 2011
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×