Skip to main content

This is yet another approach on enabling Django to load reusable, pluggable, egg-based applications without changing the Django sourcecode. Think of plugins or components, e.g. django-registration, django-threadedcomments or django-tagging.

It uses setuptools for finding, handling and loading egg-based Python modules with a specific entry point, e.g. 'django.apps'.

Egg-based Python modules (a.k.a. eggs) are compressed packaged Python modules like Django apps. Every Django app can be converted to an egg distribution by using a special setup.py file.

Installation

Get the source from the application site at:

http://code.google.com/p/django-reusableapps/

To install reusableapps, follow these steps:

  1. Follow the instructions in the INSTALL file.

  2. Add import reusableapps to the top of your settings file.

  3. Add a new setting to your settings file, a list of locations of reusable apps, in search order. Note that these paths should use Unix-style forward slashes, even on Windows.

    For example:

    REUSABLE_APPS_DIRS = (
        '/home/jannis/.local',
        '/Users/Jannis/Code/eggs',
        '/usr/share/django/apps',
        'C:/www/django/apps',
    )
  4. Add to the last line of your settings file (after the INSTALLED_APPS and REUSABLE_APPS_DIRS setting):

    INSTALLED_APPS = reusableapps.search(REUSABLE_APPS_DIRS, INSTALLED_APPS)

Putting it together

Once you finished with above installation instructions, your settings file should look something like this:

import reusableapps

# ...

REUSABLE_APPS_DIRS = (
    '/home/jannis/.local',
    '/Users/Jannis/Code/eggs',
    '/usr/share/django/apps',
    'C:/www/django/apps',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'myproject.myapp',
)

INSTALLED_APPS = reusableapps.search(REUSABLE_APPS_DIRS, INSTALLED_APPS)

You can then put reusable, pluggable, egg-based Django apps in one of the directories in REUSABLE_APPS_DIRS.

Using templates from egg-based Django apps

If you want to use templates from a egg-based Django app please add 'django.template.loaders.eggs.load_template_source' to the TEMPLATE_LOADERS setting.

Adding support for django-reusableapps to your own Django app

If you want to support django-reusableapps in your own Django app, you need to modify your existing setup.py to import the setup function from the setuptools instead the from the distutils:

from setuptools import setup

Furthermore you need to add an ‘entry point’ to the setup keywords:

entry_points={'django.apps': 'myapp = myapp'},

where my myapp is the name of your Django app, e.g. registration. A full example can be found at setup-example.py and should be copied to the parent directory of your app as setup.py. You are then able to create an egg file with of this app.

Creating egg files of reuasable Django apps

Once you have a proper setup.py in the parent directory of your Django app, you can run:

python setup.py bdist_egg

to build a egg file of it. It will be created in the dist directory and have a filename like dummyapp-0.1-py2.5.egg. You can then distribute it and use it by placing it in one of the REUSABLE_APPS_DIRS of your Django project.

Support

Please leave your questions and problems on the designated Google Code site.

Release files for django-reusableapps 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-reusableapps 0.1.1
File Size Uploaded
django-reusableapps-0.1.1.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-reusableapps 0.1.1
File Interpreter ABI Platform
django_reusableapps-0.1.1-py2.5.egg Legacy Egg format - - Details

Total release size: 14.5 kB

Release files / django-reusableapps-0.1.1.tar.gz

Download URL django-reusableapps-0.1.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
063ed5af007f0e0a0abdff4ef930b16826fac08711b7510b6e9e24821c659a41
BLAKE2b-256 checksum
How to use checksums
81ebb10d2184efa931f2d7bde8a90e348e6a11b7626f58b3cc510a806fb0e06e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_reusableapps-0.1.1-py2.5.egg

Download URL django_reusableapps-0.1.1-py2.5.egg
Size 4.8 kB
Tags Egg
SHA-256 checksum
How to use checksums
3f6e9a55aacbe30d9b740fbffed5c0bc629186f192c92e2a4987241e994821be
BLAKE2b-256 checksum
How to use checksums
ca12717a27aa5ca15a89fab69510653ffd4b2b992206f8479a41ba1983c1eabf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page