1. megantaylor
  2. django-tupperware


== What is Tupperware? ==

	Tupperware lets you move settings out of the settings.py file and into the database. 
	It allows you to have different settings for each site and automatically updates your 
	settings object for each request.

== How to install ==

	1. Make sure you have the dependencies
		- django sites (django.contrib.sites)
		- django picklefield (http://github.com/shrubberysoft/django-picklefield)

	2. Put the "tupperware" directory somewhere in your python path OR at the command line, run: $ python setup.py install
	3. Add tupperware to your installed apps (in the settings.py file)
			... other django apps...
	4. Add tupperware to the beginning of your MIDDLEWARE_CLASSES setting (settings.py):
	    	... other middleware...
	5. It is highly reccommended that you use caching (otherwise you'll be
		hitting the database for all your settings on every request). If 
		you're using a cache you need to use the tupperware cache wrapper.
		In your settings.py:
			# Your cache backend of choice (used to be the CACHE_BACKEND setting)
			CUSTOM_CACHE_BACKEND = 'file:///tmp/djangocache'
			# The tupperware cache wrapper
			CACHE_BACKEND = 'tupperware.cache_wrapper://'	
	6. create the necessary tables in the database. At the command line: 
		$ python manage.py syncdb
== Gotchas ==
	Be careful of overwriting the database settings. The settings are loaded
	from the database. It probably won't work.

	There are a few settings that you can't overwrite, mostly pertaining to
	the current site.	
	- special cases -
		settings.SITE_ID - (read only) don't try to override this setting. it 
			is loaded from site.id
		settings.SITE_NAME - loaded from (and written to) site.name
		settings.DEFAULT_FROM_EMAIL - (read only) returns noreply@{{ site.domain }} 
			you can remove the getter from tupperware.managers to make it
			act like a normal setting
		settings.CONTACT_EMAIL - (read only) returns feedback@{{ site.domain }}
			you can remove the getter from tupperware.managers to make it
			act like a normal setting		
== Using Settings from Tupperware ==

	Tupperware monkey-patches django's settings object. Just keep using django 
	settings like you always did.
		from django.conf import settings
		# This value is pulled from database. If it is not found, it uses the
		# settings.py file like normal.
== Changing settings on the fly ==

	Tupperware adds an "update" method to the settings object. It works just like
	the "update" method you see on python's built in dict object.
		from django.conf import settings
		# changes the value of settings.SOME_SETTING (stores it in the database)
		# the setting will be changed for the current site only.
	To change settings for a different site than the current site:
		from django.contrib.sites.models import Site
		from tupperware.models import SiteSetting
	    site = Site.objects.get(id=site_id)
	    }, site=site)