Skip to content

Instantly share code, notes, and snippets.

@tuxcanfly
Created October 5, 2012 06:34
Show Gist options
  • Save tuxcanfly/3838412 to your computer and use it in GitHub Desktop.
Save tuxcanfly/3838412 to your computer and use it in GitHub Desktop.

PLUGGABLE:

Django apps are supposed to be re-usable, but in practice they are not really pluggable. To integrate a app in your project, you typically need to read the docs (or source), figure out the "plug points" like urls, settings, templates, views, templatetags etc.. and then edit your settings, say a prayer or two and hope that it works.

An pluggable app should be more than just a snippet. It should provide a self-contained feature set with hassle-free integration. It should contain all info required to integrate it in a machine readable way so that the process of integrating it can be automated. Some of this info can be auto-generated by parsing the source and saved to a easily readable file, the rest would need to be filled up by the app authors.

EXAMPLE:

How I wish pluggable apps would be:

Before: https://github.com/django-debug-toolbar/django-debug-toolbar#installation

After:

python manage.py install django-debug-toolbar Installing django-debug-toolbar........

  • Depends on python package 'django-debug-toolbar', installing....done

  • Added debug_toolbar to INSTALLED_APPS

  • Added debug_toolbar.middleware.DebugToolbarMiddleware to MIDDLEWARE_CLASSES

  • Added default settings:

    • INTERNAL_IPS = ('127.0.0.1',)
  • Added optional settings:

    • DEBUG_TOOLBAR_CONFIG
    • INTERCEPT_REDIRECTS
  • This app provides:

    • Management Commands:
      • debugsqlshell
    • Middlewares:
      • debug_toolbar.middleware.DebugToolbarMiddleware

Installed successfully.

Post-install triggers:

Running syncdb.....

Post-install message:

Thanks for installing django-debug-toolbar.

Docs: https://github.com/django-debug-toolbar/django-debug-toolbar/wiki
Support: https://github.com/django-debug-toolbar/django-debug-toolbar/issues

BONUS:

When you no longer need the app:

python manage.py uninstall django-debug-toolbar

ISSUES:

  • settings.py is not easily machine writable
  • the example is biased, some apps can be harder to plug-in/out (e.g. tagging, voting etc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment