Skip to content
Permalink
Browse files

FIX Allowing upload of files without loading the whole file into memory

  • Loading branch information
LarsMichelsen committed Feb 13, 2014
1 parent 0aa4340 commit 90469813f9ad22a453b032066584e39f1d0a8053
Showing with 18 additions and 6 deletions.
  1. +8 −0 .werks/668
  2. +1 −0 ChangeLog
  3. +9 −6 web/htdocs/htmllib.py
@@ -0,0 +1,8 @@
Title: Allowing upload of files without loading the whole file into memory
Level: 1
Component: multisite
Version: 1.2.5i1
Date: 1392304629
Class: fix


@@ -217,6 +217,7 @@
* 0273 FIX: Fixed exceptions when modifying / cloning views...
* 0274 FIX: Fixed exception when view title or description was missing
* 0278 FIX: Fixed bookmark icon images for non-english user languages...
* 0668 FIX: Allowing upload of files without loading the whole file into memory

WATO:
* 0308 Multisite can now set rotation view permissions for NagVis...
@@ -1251,14 +1251,13 @@ def set_tree_states(self, tree, val):
self.load_tree_states()
self.treestates[tree] = val

def parse_field_storage(self, fields):
def parse_field_storage(self, fields, handle_uploads_as_file_obj = False):
self.vars = {}
self.listvars = {} # for variables with more than one occurrance
self.uploads = {}

for field in fields.list:
varname = field.name
value = field.value

# To prevent variours injections, we only allow a defined set
# of characters to be used in variables
@@ -1267,19 +1266,23 @@ def parse_field_storage(self, fields):

# put uploaded file infos into separate storage
if field.filename is not None:
self.uploads[varname] = (field.filename, field.type, field.value)
if handle_uploads_as_file_obj:
value = field.file
else:
value = field.value
self.uploads[varname] = (field.filename, field.type, value)

else: # normal variable
# Multiple occurrance of a variable? Store in extra list dict
if varname in self.vars:
if varname in self.listvars:
self.listvars[varname].append(value)
self.listvars[varname].append(field.value)
else:
self.listvars[varname] = [ self.vars[varname], value ]
self.listvars[varname] = [ self.vars[varname], field.value ]
# In the single-value-store the last occurrance of a variable
# has precedence. That makes appending variables to the current
# URL simpler.
self.vars[varname] = value
self.vars[varname] = field.value

def uploaded_file(self, varname, default = None):
return self.uploads.get(varname, default)

0 comments on commit 9046981

Please sign in to comment.
You can’t perform that action at this time.