Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cannot set conditions with a '<' char when others are from type "file" (
#2231) * Sort the conditions in the edition view to prevent ZPublisher's error When the value of a record received via POST should be tainted (e.g. when the value contains the character '<'), ZPublisher (at least with 4.8.2) does it, but it also does a deepcopy of the records processed earlier. If one (or more) of these records processed earlier is from file type, deepcopy cannot do the job and the following traceback arises: ``` Traceback (innermost last): Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents Module ZPublisher.WSGIPublisher, line 371, in publish_module Module ZPublisher.WSGIPublisher, line 232, in publish Module ZPublisher.HTTPRequest, line 737, in processInputs Module copy, line 163, in deepcopy\n Module copy, line 230, in _deepcopy_list Module copy, line 190, in deepcopy\n Module copy, line 334, in _reconstruct Module copy, line 163, in deepcopy\n Module copy, line 257, in _deepcopy_dict Module copy, line 190, in deepcopy\n Module copy, line 334, in _reconstruct Module copy, line 163, in deepcopy\n Module copy, line 257, in _deepcopy_dict Module copy, line 182, in deepcopy\nTypeError: can't pickle cStringIO.StringO objects ``` As a result, the base error screen from plone "We’re sorry, but there seems to be an error…" is rendered, but without any error or traceback information Relevant debug info: ``` TypeError: can't pickle cStringIO.StringO objects (Pdb++) where [...] -> self.execute() [6] /home/senaite/dev/buildout-cache/eggs/waitress-1.4.4-py2.7.egg/waitress/task.py(441)execute() -> app_iter = self.channel.server.application(environ, start_response) [7] /home/senaite/dev/buildout-cache/eggs/Paste-3.5.0-py2.7.egg/paste/translogger.py(69)__call__() -> return self.application(environ, replacement_start_response) [8] /home/senaite/dev/buildout-cache/eggs/Zope-4.8.2-py2.7.egg/ZPublisher/httpexceptions.py(30)__call__() -> return self.application(environ, start_response) [9] /home/senaite/dev/buildout-cache/eggs/Zope-4.8.2-py2.7.egg/ZPublisher/WSGIPublisher.py(371)publish_module() -> response = _publish(request, new_mod_info) [10] /home/senaite/dev/buildout-cache/eggs/Zope-4.8.2-py2.7.egg/ZPublisher/WSGIPublisher.py(232)publish() -> request.processInputs() [11] > /home/senaite/dev/buildout-cache/eggs/Zope-4.8.2-py2.7.egg/ZPublisher/HTTPRequest.py(738)processInputs() -> reclist) [12] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(163)deepcopy() -> y = copier(x, memo) [13] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(230)_deepcopy_list() -> y.append(deepcopy(a, memo)) [14] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(190)deepcopy() -> y = _reconstruct(x, rv, 1, memo) [15] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(334)_reconstruct() -> state = deepcopy(state, memo) [16] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(163)deepcopy() -> y = copier(x, memo) [17] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(257)_deepcopy_dict() -> y[deepcopy(key, memo)] = deepcopy(value, memo) [18] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(190)deepcopy() -> y = _reconstruct(x, rv, 1, memo) [19] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(334)_reconstruct() -> state = deepcopy(state, memo) [20] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(163)deepcopy() -> y = copier(x, memo) [21] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(257)_deepcopy_dict() -> y[deepcopy(key, memo)] = deepcopy(value, memo) [22] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(182)deepcopy() -> rv = reductor(2) (Pdb++) key 'conditions' (Pdb++) item '<' (Pdb++) reclist[-1] {'attachment': '', 'choices': '', 'description': '', 'required': '', 'title': 'Comentarios TGA', 'type': 'text', 'uid': '3939c785fcce47c9a3425d7e1d28aca2'} (Pdb++) reclist[-2] {'attachment': '', 'choices': '', 'description': 'Si el an\xc3\xa1lisis no se ajusta al esquema anterior, adjuntar fichero con las condiciones de ensayo', 'required': '', 'title': 'Fichero adjunto', 'type': 'file', 'uid': '3939c785fcce47c9a3425d7e1d28aca2', 'value': <ZPublisher.HTTPRequest.FileUpload object at 0x7fd973388b90>} ``` * Changelog
- Loading branch information