Browse files

crutch for lazy settings

  • Loading branch information...
1 parent b81548e commit 088ecc18278482fa3d13acd4f229b5c9653cf64b @gugu gugu committed May 16, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 actstream/settings.py
View
16 actstream/settings.py
@@ -1,9 +1,21 @@
+from UserDict import UserDict
from django.conf import settings
from django.db.models import get_model
+from django.utils.functional import memoize
-MODELS = {}
+class LazyModels(dict):
+
+ def __getitem__(self, item):
+ v = dict.__getitem__(self, item)
+ return get_model(*tuple(v))
+
+ def values(self):
+ return [get_model(*tuple(value)) for value in dict.values(self)]
+
+
+MODELS = LazyModels()
for model in getattr(settings, 'ACTSTREAM_ACTION_MODELS', ('auth.User',)):
- MODELS[model.lower()] = model = get_model(*model.split('.'))
+ MODELS[model.lower()] = model.split('.')
MANAGER_MODULE = getattr(settings, 'ACTSTREAM_MANAGER',
'actstream.managers.ActionManager')

0 comments on commit 088ecc1

Please sign in to comment.