Commit 5c38b825 authored by Elouan Martinet's avatar Elouan Martinet
Browse files

feat: remove multipart support

It is broken since Python 3 and is unused.

It is difficult to maintain support for this with CSRF checks.
parent 889440263e74
Pipeline #75523 passed with stages
in 4 minutes and 4 seconds
......@@ -94,17 +94,8 @@ class RqlIOController(Controller):
{'login': 'babar', 'pw': 'cubicweb rulez & 42'}),
('INSERT CWGroup G: G name %(name)s',
{'name': 'pachyderms'}),
('SET U in_group G WHERE G eid %(g)s, U eid %(u)s',
{'u': '__r0', 'g': '__r1'}),
('INSERT File F: F data %(content)s, F data_name %(fname)s',
{'content': '__f0', 'fname': 'toto.txt'}),
The later query is an example of query built to upload binety
data as a file object. It requires to have a multipart query
in which there is a part holding a file named '__f0'. See
cwclientlib for examples of such queries.
Limitations: back references can only work if one entity has been
......@@ -113,27 +104,15 @@ class RqlIOController(Controller):
__regid__ = "rqlio"
__select__ = (
& match_request_content_type(
"application/json", "multipart/form-data", mode="any"
& match_request_content_type("application/json")
& match_form_params("version")
require_csrf = False
def json(self):
contenttype = self._cw.get_header("Content-Type", raw=False)
if (contenttype.mediaType, contenttype.mediaSubtype) == (
): # noqa: E501
encoding = contenttype.params.get("charset", "utf-8")
content = self._cw.content
# Multipart content is usually built by
# cubicweb.multipart.parse_form_data() which encodes using
# "utf-8" by default.
encoding = "utf-8"
content = self._cw.form["json"][1]
encoding = contenttype.params.get("charset", "utf-8")
content = self._cw.content
# here we use .read instead of .gevalue because
# on some circumstances content is an instance of BufferedRandom
......@@ -95,30 +95,6 @@ class RqlIOTC(PyramidCWTest):
self.assertEqual(2, len(output[2]))
self.assertEqual([output[0][0], output[1][0]], output[2])
def test_queries_multipart(self):
queries = [
"INSERT CWUser U: U login %(l)s, U upassword %(p)s",
{"l": "Babar", "p": "cubicweb rulez & 42"},
('INSERT CWGroup G: G name "pachyderms"', {}),
"SET U in_group G WHERE U eid %(u)s, G eid %(g)s",
{"u": "__r0", "g": "__r1"},
self.webapp.login(user="admin", password=self.password)
files = [("json", "loutre.json", json.dumps(queries).encode("utf-8"))]
"Accept": "application/json",
def test_rewrite_args_errors(self):
rql1 = "Any U WHERE U login %(l)s"
rql2 = 'SET U in_group G WHERE G name "managers", U eid %(u)s'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment