Fixed indent and refactored ikflush command (issue #19)

This commit is contained in:
Justin Driscoll 2009-08-10 14:30:41 -04:00
parent eb97ed1180
commit 1d82a64bd7

View file

@ -20,19 +20,17 @@ def flush_cache(apps, options):
"""
apps = [a.strip(',') for a in apps]
if apps:
print 'Flushing cache for %s...' % ', '.join(apps)
for app_label in apps:
app = cache.get_app(app_label)
models = [m for m in cache.get_models(app) if issubclass(m, ImageModel)]
for model in models:
print 'Flushing cache for "%s.%s"' % (app_label, model.__name__)
for obj in model.objects.all():
for spec in model._ik.specs:
prop = getattr(obj, spec.name(), None)
if prop is not None:
prop._delete()
if spec.pre_cache:
prop._create()
else:
print 'Flushing caches...'
for app_label in apps:
app = cache.get_app(app_label)
models = [m for m in cache.get_models(app) if issubclass(m, ImageModel)]
for model in models:
for obj in model.objects.all():
for spec in model._ik.specs:
prop = getattr(obj, spec.name(), None)
if prop is not None:
prop._delete()
if spec.pre_cache:
prop._create()
print 'Please specify on or more app names'