mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
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).
This commit is contained in:
parent
f8b3b944aa
commit
030d2ec16c
1 changed files with 7 additions and 4 deletions
|
@ -919,15 +919,18 @@ class FieldStorage:
|
||||||
self.list.append(MiniFieldStorage(key, value))
|
self.list.append(MiniFieldStorage(key, value))
|
||||||
self.skip_lines()
|
self.skip_lines()
|
||||||
|
|
||||||
|
FieldStorageClass = None
|
||||||
|
|
||||||
def read_multi(self, environ, keep_blank_values, strict_parsing):
|
def read_multi(self, environ, keep_blank_values, strict_parsing):
|
||||||
"""Internal: read a part that is itself multipart."""
|
"""Internal: read a part that is itself multipart."""
|
||||||
self.list = []
|
self.list = []
|
||||||
part = self.__class__(self.fp, {}, self.innerboundary,
|
klass = self.FieldStorageClass or self.__class__
|
||||||
|
part = klass(self.fp, {}, self.innerboundary,
|
||||||
environ, keep_blank_values, strict_parsing)
|
environ, keep_blank_values, strict_parsing)
|
||||||
# Throw first part away
|
# Throw first part away
|
||||||
while not part.done:
|
while not part.done:
|
||||||
headers = rfc822.Message(self.fp)
|
headers = rfc822.Message(self.fp)
|
||||||
part = self.__class__(self.fp, headers, self.innerboundary,
|
part = klass(self.fp, headers, self.innerboundary,
|
||||||
environ, keep_blank_values, strict_parsing)
|
environ, keep_blank_values, strict_parsing)
|
||||||
self.list.append(part)
|
self.list.append(part)
|
||||||
self.skip_lines()
|
self.skip_lines()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue