def test_get_url(self): # Build a fake resource and a fake DataPreviewController # and make sure that _get_url correctly decodes the UTF-8 r = Resource(url="") p = os.path.join(os.path.dirname(__file__), "data/utf8/*.xls") p = glob.glob(p) r.extras['cache_filepath'] = p[0].decode('utf8') ctr = DataPreviewController() s = ctr._get_url(r, {}) assert s == r.extras['cache_filepath']
def publish_ogc(self): """ Publishes the resource content into Geoserver. Shape file and csv files are handled differently. """ context = { 'model': model, 'session': model.Session, 'user': c.user or c.author } data = clean_dict(unflatten(tuplize_dict(parse_params( request.params)))) res = Resource().get(data['id']) uri = Resource().get(data['id']).extras['content_model_version'] url = res.url if url[len(url) - 3:len(url)] == 'zip': action.shapefile_expose_as_layer(context, data) if url[len(url) - 3:len(url)] == 'csv': action.datastore_spatialize(context, data) return {'success': True, 'url': url}