Ticket #20034: 0001-Modified-upload-handler-API-to-be-able-to-invoke-cal.patch

File 0001-Modified-upload-handler-API-to-be-able-to-invoke-cal.patch, 1.9 KB (added by rfkrocktk@…, 11 years ago)

Patch for the bug.

  • django/core/files/uploadhandler.py

    From ffa2d2e3d7a6af2a5fa1f5612af6ac95c4b8e987 Mon Sep 17 00:00:00 2001
    From: TK Kocheran <rfkrocktk@gmail.com>
    Date: Tue, 12 Mar 2013 19:17:45 -0700
    Subject: [PATCH] Modified upload handler API to be able to invoke callbacks
     when new fields/variables are successfully parsed from
     multipart POST request. Fix for #20034.
    
    ---
     django/core/files/uploadhandler.py |    6 ++++++
     django/http/multipartparser.py     |    7 +++++++
     2 files changed, 13 insertions(+)
    
    diff --git a/django/core/files/uploadhandler.py b/django/core/files/uploadhandler.py
    index f5e95cf..080b5d3 100644
    a b class FileUploadHandler(object):  
    8484        """
    8585        pass
    8686
     87    def variable_complete(self, variable_name, variable_value):
     88        """
     89        Signal that a new variable has been parsed from the multipart request.
     90        """
     91        pass
     92
    8793    def new_file(self, field_name, file_name, content_type, content_length, charset=None):
    8894        """
    8995        Signal that a new file has been started.
  • django/http/multipartparser.py

    diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py
    index 070874f..dc66cc3 100644
    a b class MultiPartParser(object):  
    167167
    168168                    self._post.appendlist(field_name,
    169169                                          force_text(data, encoding, errors='replace'))
     170                   
     171                    for handler in handlers:
     172                        try :
     173                            handler.variable_complete(field_name, force_text(data, encoding, errors='replace'))
     174                        except StopFutureHandlers:
     175                            break
     176
    170177                elif item_type == FILE:
    171178                    # This is a file, use the handler...
    172179                    file_name = disposition.get('filename')
Back to Top