Skip to content

Issue/conneg#71

Merged
white-gecko merged 1 commit intofeature/provenancefrom
issue/conneg
Nov 1, 2017
Merged

Issue/conneg#71
white-gecko merged 1 commit intofeature/provenancefrom
issue/conneg

Conversation

@splattater
Copy link
Copy Markdown
Contributor

Fixes #68

@coveralls
Copy link
Copy Markdown

coveralls commented Oct 20, 2017

Coverage Status

Coverage decreased (-0.5%) to 53.445% when pulling 2e374ba on issue/conneg into 36193f9 on feature/provenance.

@coveralls
Copy link
Copy Markdown

coveralls commented Oct 20, 2017

Coverage Status

Coverage increased (+5.9%) to 59.91% when pulling 1519249 on issue/conneg into 36193f9 on feature/provenance.

Copy link
Copy Markdown
Member

@white-gecko white-gecko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash.

queryTypeRegex += r"INSERT|DELETE|CREATE|CLEAR|DROP|LOAD|COPY|MOVE|ADD"
queryTypeRegex += r"))"
queryTypeRegex = r"""
(?P<queryType>(CONSTRUCT|SELECT|ASK|DESCRIBE|queryTypeRegexINSERT|DELETE|
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a superfluous queryTypeRegex

response.headers['Content-Type'] = 'text/html'
return response
elif mimetype in ['application/json', 'application/sparql-results+json']:
elif mimetype in ['application/sparql-results+json']:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.w3.org/TR/sparql11-results-json/

Please support application/json and application/sparql-results+json

elif mimetype in [
'application/rdf+xml', 'application/xml', 'application/sparql-results+xml'
]:
elif mimetype in ['application/sparql-results+xml']:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also accept application/xml here.

response = make_response(res.serialize(format='xml'), 200)
response.headers['Content-Type'] = 'application/rdf+xml'
return response
elif mimetype in ['text/turtle']:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also support the old turtle mime type: application/x-turtle

response = make_response(res.serialize(format='nt'), 200)
response.headers['Content-Type'] = 'application/n-triples'
return response
else:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n-quads is missing.

response.headers['Content-Type'] = 'application/n-triples'
return response
else:
return make_response('', 406)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@splattater splattater force-pushed the issue/conneg branch 2 times, most recently from 820038e to d53aa4c Compare October 24, 2017 11:07
@coveralls
Copy link
Copy Markdown

coveralls commented Oct 24, 2017

Coverage Status

Coverage increased (+5.01%) to 59.141% when pulling d53aa4c on issue/conneg into e4e8477 on feature/provenance.

2 similar comments
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+5.01%) to 59.141% when pulling d53aa4c on issue/conneg into e4e8477 on feature/provenance.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+5.01%) to 59.141% when pulling d53aa4c on issue/conneg into e4e8477 on feature/provenance.

return render_template('provenance.html')


def create_result_response(res, querytype, mimetype):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change signature to create_result_response(res, mimetype, mimetypes[mimetype])


# Set default
if mimetype == '*/*':
mimetype = 'text/turtle'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you know

queryTypeRegex = r"""
(?P<queryType>(CONSTRUCT|SELECT|ASK|DESCRIBE|INSERT|DELETE|
CREATE|CLEAR|DROP|LOAD|COPY|MOVE|ADD))
"""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the regex is still the same?

@splattater
Copy link
Copy Markdown
Contributor Author

Will be rebased and squashed after final review

Copy link
Copy Markdown
Member

@white-gecko white-gecko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor changes

def parse_query_type(query):
try:
query_type = queryTypePattern.search(query).group("queryType").upper()
return query_type
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can make this:
return queryTypePattern.search(query).group("queryType").upper()

return response
else:
if query_type in ['SELECT', 'ASK']:
querytype = 'query'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having query_type and querytype as two different variables is misleading.

dict_part = mimetypes[querytype][mimetype]
return create_result_response(res, dict_part)
except KeyError as e:
return make_response('Mimetype: ' + mimetype + ' not Acceptable', 406)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you change this to a format(mimetype).

@coveralls
Copy link
Copy Markdown

coveralls commented Nov 1, 2017

Coverage Status

Coverage increased (+5.4%) to 58.999% when pulling 8088b93 on issue/conneg into 6ea54e0 on feature/provenance.

@coveralls
Copy link
Copy Markdown

coveralls commented Nov 1, 2017

Coverage Status

Coverage increased (+5.4%) to 58.985% when pulling edec8ff on issue/conneg into 6ea54e0 on feature/provenance.

1 similar comment
@coveralls
Copy link
Copy Markdown

coveralls commented Nov 1, 2017

Coverage Status

Coverage increased (+5.4%) to 58.985% when pulling edec8ff on issue/conneg into 6ea54e0 on feature/provenance.

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.
@coveralls
Copy link
Copy Markdown

coveralls commented Nov 1, 2017

Coverage Status

Coverage increased (+5.4%) to 58.985% when pulling 696aa32 on issue/conneg into 6ea54e0 on feature/provenance.

@white-gecko white-gecko merged commit 0f760d9 into feature/provenance Nov 1, 2017
@white-gecko white-gecko deleted the issue/conneg branch November 1, 2017 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants