コード例 #1
0
    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']
コード例 #2
0
    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']
コード例 #3
0
def resource_update(context, data_dict):
    log.debug(data_dict)
    model = context['model']
    resource = Resource.get(data_dict['id'])
    extras = resource.extras
    if resource is not None and 'url' not in data_dict:
        url = resource.url
        data_dict['url'] = url
    resource_dict = update.resource_update(context, data_dict)
    resource = Resource.get(data_dict['id'])
    if len(resource.extras) <= 0:
        resource.extras = extras
    model.repo.commit()
    for key in resource.extras:
        resource_dict[key] = resource.extras[key]

    send_resource_log(context, resource_dict, 'Resource metadata updated',
                      'ResourceMetadataUpdated')

    return resource_dict
コード例 #4
0
    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}
コード例 #5
0
def is_ogc_publishable(resource_id):
    resource = Resource.get(resource_id)
    url = resource.url
    if url[len(url) - 3:len(url)] == 'zip' or url[len(url) - 3:len(url)] == 'csv':
        return True
    return False