django-tupperware /

Filename Size Date modified Message
34.3 KB
3.2 KB
1.1 KB
== What is Tupperware? ==

	Tupperware lets you move settings out of the 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 (

	2. Put the "tupperware" directory somewhere in your python path 
		OR at the command line, run: $ python install
	3. Add tupperware to your installed apps (in the file)
			... other django apps...
	4. Add tupperware to the beginning of your MIDDLEWARE_CLASSES setting (
	    	... 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
			# 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 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
		settings.SITE_NAME - loaded from (and written to)
		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
		# 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)
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.