Skip to content

Commit

Permalink
Some refactoring of get_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
koenedaele committed May 13, 2016
1 parent d940b99 commit 3dbc11d
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions pyramid_skosprovider/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ class ProviderView(RestView):
@view_config(route_name='skosprovider.uri', request_method='GET')
@view_config(route_name='skosprovider.uri.deprecated', request_method='GET')
def get_uri(self):
uri = self.request.params.get('uri')
uri = self.request.params.get('uri', self.request.matchdict.get('uri', None))
if not uri:
if 'uri' in self.request.matchdict:
uri = self.request.matchdict['uri']
else:
return HTTPBadRequest()
return HTTPBadRequest()
provider = self.skos_registry.get_provider(uri)
if provider:
return {
Expand All @@ -55,18 +52,17 @@ def get_uri(self):
'id': provider.get_vocabulary_id()
}
c = self.skos_registry.get_by_uri(uri)
if c:
return {
'type': c.type,
'uri': c.uri,
'id': c.id,
'concept_scheme': {
'uri': c.concept_scheme.uri,
'id': self.skos_registry.get_provider(c.concept_scheme.uri).get_vocabulary_id()
}
}
if not c:
return HTTPNotFound()
return {
'type': c.type,
'uri': c.uri,
'id': c.id,
'concept_scheme': {
'uri': c.concept_scheme.uri,
'id': self.skos_registry.get_provider(c.concept_scheme.uri).get_vocabulary_id()
}
}

@view_config(route_name='skosprovider.conceptschemes', request_method='GET')
def get_conceptschemes(self):
Expand Down

0 comments on commit 3dbc11d

Please sign in to comment.