Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 030d2ec

Browse files
committed
In read_multi, allow a subclass to override the class we instantiate
when we create a recursive instance, by setting the class variable 'FieldStorageClass' to the desired class. By default, this is set to None, in which case we use self.__class__ (as before).
1 parent f8b3b94 commit 030d2ec

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Lib/cgi.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -919,16 +919,19 @@ def read_urlencoded(self):
919919
self.list.append(MiniFieldStorage(key, value))
920920
self.skip_lines()
921921

922+
FieldStorageClass = None
923+
922924
def read_multi(self, environ, keep_blank_values, strict_parsing):
923925
"""Internal: read a part that is itself multipart."""
924926
self.list = []
925-
part = self.__class__(self.fp, {}, self.innerboundary,
926-
environ, keep_blank_values, strict_parsing)
927+
klass = self.FieldStorageClass or self.__class__
928+
part = klass(self.fp, {}, self.innerboundary,
929+
environ, keep_blank_values, strict_parsing)
927930
# Throw first part away
928931
while not part.done:
929932
headers = rfc822.Message(self.fp)
930-
part = self.__class__(self.fp, headers, self.innerboundary,
931-
environ, keep_blank_values, strict_parsing)
933+
part = klass(self.fp, headers, self.innerboundary,
934+
environ, keep_blank_values, strict_parsing)
932935
self.list.append(part)
933936
self.skip_lines()
934937

0 commit comments

Comments
 (0)