Conversation
quit/web/modules/endpoint.py
Outdated
| queryTypeRegex += r"INSERT|DELETE|CREATE|CLEAR|DROP|LOAD|COPY|MOVE|ADD" | ||
| queryTypeRegex += r"))" | ||
| queryTypeRegex = r""" | ||
| (?P<queryType>(CONSTRUCT|SELECT|ASK|DESCRIBE|queryTypeRegexINSERT|DELETE| |
There was a problem hiding this comment.
there is a superfluous queryTypeRegex
quit/web/modules/endpoint.py
Outdated
| response.headers['Content-Type'] = 'text/html' | ||
| return response | ||
| elif mimetype in ['application/json', 'application/sparql-results+json']: | ||
| elif mimetype in ['application/sparql-results+json']: |
There was a problem hiding this comment.
https://www.w3.org/TR/sparql11-results-json/
Please support application/json and application/sparql-results+json
quit/web/modules/endpoint.py
Outdated
| elif mimetype in [ | ||
| 'application/rdf+xml', 'application/xml', 'application/sparql-results+xml' | ||
| ]: | ||
| elif mimetype in ['application/sparql-results+xml']: |
There was a problem hiding this comment.
Please also accept application/xml here.
quit/web/modules/endpoint.py
Outdated
| response = make_response(res.serialize(format='xml'), 200) | ||
| response.headers['Content-Type'] = 'application/rdf+xml' | ||
| return response | ||
| elif mimetype in ['text/turtle']: |
There was a problem hiding this comment.
please also support the old turtle mime type: application/x-turtle
quit/web/modules/endpoint.py
Outdated
| response = make_response(res.serialize(format='nt'), 200) | ||
| response.headers['Content-Type'] = 'application/n-triples' | ||
| return response | ||
| else: |
quit/web/modules/endpoint.py
Outdated
| response.headers['Content-Type'] = 'application/n-triples' | ||
| return response | ||
| else: | ||
| return make_response('', 406) |
There was a problem hiding this comment.
Maybe this could be replaced by some dictionary:
mimetype -> serializername
the response header content-type should correstpond to the best matching requested content type which was selected for serialization.
820038e to
d53aa4c
Compare
2 similar comments
quit/web/modules/endpoint.py
Outdated
| return render_template('provenance.html') | ||
|
|
||
|
|
||
| def create_result_response(res, querytype, mimetype): |
There was a problem hiding this comment.
change signature to create_result_response(res, mimetype, mimetypes[mimetype])
quit/web/modules/endpoint.py
Outdated
|
|
||
| # Set default | ||
| if mimetype == '*/*': | ||
| mimetype = 'text/turtle' |
| queryTypeRegex = r""" | ||
| (?P<queryType>(CONSTRUCT|SELECT|ASK|DESCRIBE|INSERT|DELETE| | ||
| CREATE|CLEAR|DROP|LOAD|COPY|MOVE|ADD)) | ||
| """ |
There was a problem hiding this comment.
Are you sure the regex is still the same?
|
Will be rebased and squashed after final review |
quit/web/modules/endpoint.py
Outdated
| def parse_query_type(query): | ||
| try: | ||
| query_type = queryTypePattern.search(query).group("queryType").upper() | ||
| return query_type |
There was a problem hiding this comment.
you can make this:
return queryTypePattern.search(query).group("queryType").upper()
quit/web/modules/endpoint.py
Outdated
| return response | ||
| else: | ||
| if query_type in ['SELECT', 'ASK']: | ||
| querytype = 'query' |
There was a problem hiding this comment.
Having query_type and querytype as two different variables is misleading.
quit/web/modules/endpoint.py
Outdated
| dict_part = mimetypes[querytype][mimetype] | ||
| return create_result_response(res, dict_part) | ||
| except KeyError as e: | ||
| return make_response('Mimetype: ' + mimetype + ' not Acceptable', 406) |
There was a problem hiding this comment.
Maybe you change this to a format(mimetype).
2b2639a to
8088b93
Compare
1 similar comment
edec8ff to
1859cfc
Compare
Add more supported mime types. Distinguish mime types between Select/Ask and Construct/Describe. Update default mime types. Add HTTP responds on error. Add conneq tests. Add a dictionary containing accept type, content type and rdflib serialization format for both, CONSTRUCT/DESCRIBE and SELECT/ASK queries. Add a method that creates responses in the requested serialization. This method deduplicates code of sparql and provenance method/path. Add raise of UnSupportedQueryType Update exception handling Update app versioning test Add endpoint test class Add test for parse_query_type method.
1859cfc to
696aa32
Compare
Fixes #68