-
-
Save mmalone/177707 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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