Commits

Matthew Schinckel committed 8ab2cf3

Better handling of missing fields.
Don't re-create an HttpResponse.

  • Participants
  • Parent commits 2d4ae7a

Comments (0)

Files changed (2)

File repose/forms.py

     def updated_message(self):
         raise NotImplemented('You must define the updated_message')
     
+    def __setattr__(self, attr, value):
+        if attr == 'data':
+            import pdb; pdb.set_trace()
+        return super(BaseApiForm, self).__setattr__(attr, value)
+    
 class BaseApiModelForm(forms.ModelForm):
     """
     A handy subclass of ModelForm that adds a non-required id field. This allows
         if self.instance:
             old_data = forms.models.model_to_dict(self.instance)
             for field in self.readonly_fields:
-                self.data[field] = old_data[field]
+                if field in old_data:
+                    self.data[field] = old_data[field]
                 
     def get_changed_fields(self):
         """

File repose/views.py

         else:
             if self.etag_function:
                 etag = self.etag_function(response)
-            form = self.bind_form(response)
             
-            response = http.OK(form)
+            if not isinstance(response, http.BaseHttpResponse):
+                form = self.bind_form(response)
+                response = http.OK(form)
             
             if self.etag_function:
                 response['Etag'] = etag