Make ContextForm and ContextModelForm work again.
authorMatthijs Kooijman <matthijs@stdin.nl>
Tue, 28 Oct 2008 22:33:42 +0000 (23:33 +0100)
committerMatthijs Kooijman <matthijs@stdin.nl>
Tue, 28 Oct 2008 22:33:42 +0000 (23:33 +0100)
It seems like some stuff changed in django, not sure what exactly. This
commit removes changes the inheritance to inherit from Form and
ModelForm instead of avoiding that and directly inheriting from their
base classes and do some metaclass magic.

tools/forms.py

index 657940e309aecf13c669f3022da78f14cca53205..db65a99c43da663820675de8aa2aff76b9f83f1f 100644 (file)
@@ -1,10 +1,10 @@
 # Mostly based on code from Amelie, a project by Inter-Actief.
 
 from django.forms.util import ErrorList
-from django.forms.models import BaseModelForm, ModelFormMetaclass
-from django.forms.forms import BaseForm, DeclarativeFieldsMetaclass
+from django.forms.models import ModelForm
+from django.forms.forms import Form
 
-class BaseContextForm(BaseForm):
+class ContextForm(Form):
     def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
                  initial=None, request=None, error_class=ErrorList, label_suffix=':'):
         self.request = request
@@ -13,13 +13,10 @@ class BaseContextForm(BaseForm):
                 data = request.POST
             if not files:
                 files = request.FILES
-        super(BaseContextForm, self).__init__(data, files, auto_id, prefix,
+        super(ContextForm, self).__init__(data, files, auto_id, prefix,
                                        initial, request, error_class, label_suffix)
 
-class ContextForm(BaseContextForm):
-    __metaclass__ = DeclarativeFieldsMetaclass
-
-class BaseContextModelForm(BaseModelForm):
+class ContextModelForm(ModelForm):
     def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
                  initial=None, request=None, error_class=ErrorList, label_suffix=':', instance=None):
         self.request = request
@@ -28,10 +25,8 @@ class BaseContextModelForm(BaseModelForm):
                 data = request.POST
             if not files:
                 files = request.FILES
-        super(BaseContextModelForm, self).__init__(data, files, auto_id, prefix, initial, 
+        super(ContextModelForm, self).__init__(data, files, auto_id, prefix, initial, 
                                             error_class, label_suffix, instance)
 
-class ContextModelForm(BaseContextModelForm):
-    __metaclass__ = ModelFormMetaclass
 
 # vim: set sts=4 sw=4 expandtab: