Commits

Luke Plant committed e0e3662

Removed trailing whitespace

Comments (0)

Files changed (1)

lukeplant_me_uk/django/validator/models.py

     request = models.TextField("Request object", default='', blank=True)
     response = models.TextField("Response object", default='', blank=True)
     errors = models.TextField("Errors")
-    
+
     def __repr__(self):
         return self.method + " " + self.path
 
             return cPickle.loads(base64.decodestring(self.response))
         except EOFError, UnpicklingError:
             return None
-  
+
     class Meta:
         ordering = ('-timestamp',)
-  
+
     class Admin:
         fields =  (
             (None, {'fields': ('timestamp', 'path', 'method', 'errors')}),
         )
 
-      
+
     def do_validation(request, response):
         """Do validation on response and log if it fails."""
         from django.conf import settings
             VALIDATOR_APP_IGNORE_PATHS = settings.VALIDATOR_APP_IGNORE_PATHS
         except AttributeError:
             VALIDATOR_APP_IGNORE_PATHS = ()
-                  
+
         import tempfile
         import cPickle
         import os
         import copy
-        
+
         try:
             content_type = response['Content-Type'].split(';')[0]
             validator = settings.VALIDATOR_APP_VALIDATORS[content_type]
         except KeyError, IndexError:
             # no content type, or no validator for that content type
             return
-            
+
         for ignore_path in VALIDATOR_APP_IGNORE_PATHS:
             if request.path.startswith(ignore_path):
                 return
-        
+
         # first store data in temporary file
         (tmpfilehandle, tmpfilepath) = tempfile.mkstemp()
         os.write(tmpfilehandle, response.content)
         os.close(tmpfilehandle)
-        
+
         # Now execute validator and get result
         (child_stdin, child_output) = os.popen4(validator + ' ' + tmpfilepath)
         errors = child_output.read()
-        
+
         # Normalise output so that we can eliminate duplicate errors
         errors = errors.replace(tmpfilepath, '[tmpfilepath]')
-        
+
         # clean up
         child_stdin.close()
         child_output.close()
         # (this isn't perfectly watertight -- you could by chance be
         # generating identical errors with different query strings or
         # POST data, but it's unlikely).
-        
+
         if len(errors) > 0 and \
                ValidationFailure.objects.filter(errors=errors,
                                                 path=request.path).count() == 0:
             failure.errors = errors
 
             from django.core.handlers.modpython import ModPythonRequest
-            
+
             if isinstance(request, ModPythonRequest):
                 # prepopulate vars
                 request._get_get()
                 except Exception, e:
                     # TODO - work out why this happens
                     req = "Couldn't stash a copy of the request: %s" % str(e)
-            
+
             failure.request = base64.encodestring(cPickle.dumps(req))
             failure.response = base64.encodestring(cPickle.dumps(response))
             failure.method = request.META['REQUEST_METHOD']
             failure.save()
-    do_validation = staticmethod(do_validation)    
+    do_validation = staticmethod(do_validation)