Remove old API in Pylons controller
This commit is contained in:
parent
2b26b7c746
commit
322a92bcec
|
@ -1,50 +1,15 @@
|
|||
import logging
|
||||
|
||||
from pylons import response
|
||||
|
||||
from ckan.lib.base import request, abort
|
||||
from ckan.lib.base import abort
|
||||
from ckan.controllers.api import ApiController as BaseApiController
|
||||
from ckan.model import Session
|
||||
|
||||
from ckanext.harvest.model import HarvestObject, HarvestObjectExtra
|
||||
from ckanext.spatial.lib import get_srid, validate_bbox, bbox_query
|
||||
from ckanext.spatial import util
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ApiController(BaseApiController):
|
||||
|
||||
def spatial_query(self):
|
||||
|
||||
error_400_msg = \
|
||||
'Please provide a suitable bbox parameter [minx,miny,maxx,maxy]'
|
||||
|
||||
if 'bbox' not in request.params:
|
||||
abort(400, error_400_msg)
|
||||
|
||||
bbox = validate_bbox(request.params['bbox'])
|
||||
|
||||
if not bbox:
|
||||
abort(400, error_400_msg)
|
||||
|
||||
srid = get_srid(request.params.get('crs')) if 'crs' in \
|
||||
request.params else None
|
||||
|
||||
extents = bbox_query(bbox, srid)
|
||||
|
||||
format = request.params.get('format', '')
|
||||
|
||||
return self._output_results(extents, format)
|
||||
|
||||
def _output_results(self, extents, format=None):
|
||||
|
||||
ids = [extent.package_id for extent in extents]
|
||||
output = dict(count=len(ids), results=ids)
|
||||
|
||||
return self._finish_ok(output)
|
||||
|
||||
|
||||
class HarvestMetadataApiController(BaseApiController):
|
||||
|
||||
def _get_content(self, id):
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
import ckan.plugins as p
|
||||
|
||||
|
||||
|
||||
class SpatialQueryMixin(p.SingletonPlugin):
|
||||
p.implements(p.IRoutes, inherit=True)
|
||||
pass
|
||||
|
||||
# IRoutes
|
||||
def before_map(self, map):
|
||||
map.connect('api_spatial_query', '/api/2/search/{register:dataset|package}/geo',
|
||||
controller='ckanext.spatial.controllers.api:ApiController',
|
||||
action='spatial_query')
|
||||
return map
|
||||
|
||||
class HarvestMetadataApiMixin(p.SingletonPlugin):
|
||||
p.implements(p.IRoutes, inherit=True)
|
||||
|
|
Loading…
Reference in New Issue