Created
August 29, 2009 22:31
-
-
Save joestump/177706 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 AppCache | |
from django.conf import settings | |
import simpledb | |
class Command(BaseCommand): | |
help = ("Sync all of the SimpleDB domains.") | |
def handle(self, *args, **options): | |
apps = AppCache() | |
check = [] | |
for module in apps.get_apps(): | |
for d in module.__dict__: | |
ref = getattr(module, d) | |
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 list(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