Skip to content

Instantly share code, notes, and snippets.

@mmalone
Forked from joestump/gist:177706
Created August 29, 2009 22:32
Show Gist options
  • Save mmalone/177707 to your computer and use it in GitHub Desktop.
Save mmalone/177707 to your computer and use it in GitHub Desktop.
from django.core.management.base import BaseCommand, CommandError
from django.db.models.loading import get_apps
from django.conf import settings
import simpledb
class Command(BaseCommand):
help = ("Sync all of the SimpleDB domains.")
def handle(self, *args, **options):
check = []
for module in get_apps():
for d, ref in module.__dict__.iteritems():
if isinstance(ref, simpledb.models.ModelMetaclass):
domain = ref.Meta.domain.name
if domain not in check:
check.append(domain)
sdb = simpledb.SimpleDB(settings.AWS_KEY, settings.AWS_SECRET)
domains = [d.name for d in sdb]
for c in check:
if c not in domains:
sdb.create_domain(c)
print "Creating domain %s ..." % c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment