Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!


This app will make it easy to customize external Django apps 
that use it.

It takes an approach very similar to the django.contrib.comments 
framework. It makes it easy to use custom forms, values, etc.

Quick example...

Say you have an open source Django app that lets you upload a 
Photo and some metadata to that photo. To be able to customize 
that form, the project owners would have to hack the app's 
source to fit their needs (class names, etc.) or you have to 
make your app customizable. That's where django-easyconfig 
comes in...


Basic Install:

  $ python build
  $ sudo python install

Alternative Install (Manually):

Place webutils directory in your Python path. Either in your Python 
installs site-packages directory or set your $PYTHONPATH environment 
variable to include a directory where the webutils directory lives.


* XXX * These are not great docs. I'll work on updating this soon!

You must create a "Config" object in your app and use that to fetch 
any object or value you want to be able to have customized.

Here is a basic example.

### yourapp/

from django.contrib.auth.forms import AuthenticationForm
from yourapp.forms import PasswordChangeForm
from easyconfig import EasyConfig

class Config(object):
    ''' Base config class to easily pass forms, etc. to 
        yourapp views.
    # Use the dotted Python path to this class
    config = EasyConfig('yourapp.Config', 'YOURAPP_CONFIG')
    def get_login_form(self):
        return self.config.get_object('get_login_form', AuthenticationForm)

    def get_password_change_form(self):
        return self.config.get_object('get_password_change_form', PasswordChangeForm)

Now, you just need to use your yourapp.Config class any time you need 
to fetch one of these objects for use.

Here's how it could be used in a file


from yourapp import Config
from django.conf.urls.defaults import *

config = Config()

urlpatterns = patterns('yourapp.views',
        'login', {
            'template_name': 'yourapp/login.html',
            'authentication_form': config.get_login_form(),
        }, name='yourapp-login'),
        'passwd_change', {
            'template_name': 'yourapp/passwd_change.html',
            'passwd_change_form': config.get_password_change_form(),
        }, name='yourapp-passwd-change'),

Now, anybody using your app in their own project can easily change the 
login and password change forms to whatever form they want. Here is how
they would do so in their own project.


# Dotted python path to their own CustomConfig class
YOURAPP_CONFIG = 'myproject.myapp.CustomConfig'

### myproject/myapp/

from myproject.myapp.forms import AuthForm, ChangeForm

class CustomConfig(object):    
    ''' Customize the forms!
    def get_login_form(self):
        return AuthForm
    def get_password_change_form(self):
        return ChangeForm

That's it. Easy right? :)

Copyright & Warranty
All documentation, libraries, and sample code are 
Copyright 2010 Peter Sanchez <>. The library and 
sample code are made available to you under the terms of the BSD license 
which is contained in the included file, BSD-LICENSE.

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.