Added crude double-import detection to search registration. Added Django 1.2 fallback...
authorStephen Burrows <stephen.r.burrows@gmail.com>
Tue, 12 Apr 2011 20:21:44 +0000 (16:21 -0400)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Tue, 12 Apr 2011 20:25:01 +0000 (16:25 -0400)
contrib/sobol/search.py
models/fields/__init__.py

index 36c2b5d..843af81 100644 (file)
@@ -42,8 +42,9 @@ class SearchRegistry(object):
        def register(self, search, slug=None):
                slug = slug or search.slug
                if slug in self._registry:
        def register(self, search, slug=None):
                slug = slug or search.slug
                if slug in self._registry:
-                       if self._registry[slug] != search:
-                               raise RegistrationError("A different search is already registered as `%s`")
+                       registered = self._registry[slug]
+                       if registered.__module__ != search.__module__:
+                               raise RegistrationError("A different search is already registered as `%s`" % slug)
                else:
                        self._registry[slug] = search
        
                else:
                        self._registry[slug] = search
        
index 1f9603e..d900e31 100644 (file)
@@ -109,7 +109,8 @@ class SlugMultipleChoiceField(models.Field):
                                del kwargs[k]
                
                defaults.update(kwargs)
                                del kwargs[k]
                
                defaults.update(kwargs)
-               form_class = forms.TypedMultipleChoiceField
+               # Django 1.2 does not supply MultipleChoiceField
+               form_class = getattr(forms, 'TypedMultipleChoiceField', forms.MultipleChoiceField)
                return form_class(**defaults)
        
        def validate(self, value, model_instance):
                return form_class(**defaults)
        
        def validate(self, value, model_instance):