ckan / ckanext-spatial

Geospatial extension for CKAN
http://docs.ckan.org/projects/ckanext-spatial
126 stars 193 forks source link

'CswService' object has no attribute 'startswith' #310

Closed sneuvonen closed 1 year ago

sneuvonen commented 1 year ago

Dear all,

Apologies, if this does not qualify as an issue but I can't imagine what I could have done wrong to cause it, so...

After installing CKAN 2.10 and extensions harvest and spatial, I started the gather- & fetch-processes and then a newly created CSW-harvester from web-UI. In the terminal running gather-job I received the following:

2023-06-02 07:57:25,977 INFO [ckanext.harvest.model] Error contacting the CSW server: 'CswService' object has no attribute 'startswith' 2023-06-02 07:57:25,982 ERROR [ckanext.harvest.queue] Gather stage failed

I figure this traces back to file csw.py (row 75) and the initiation of the CswService, going further all the way to OWSLib. I have tried to debug but as far as I can tell, a simple string url is passed on, so I can't figure out why/how/where this can go wrong.

edelater commented 1 year ago

I'm running into the same problem. Unfortunately I don't know too much about python.

What I think is going wrong is that the url that gets passed to CatalogueServiceWeb from csw.py and csw_client.py is not a string, but a CswService object. And then the error comes from the line clean_url = clean_ows_url(url) (see util.py).

Weird thing is that it looks like both the relevant code from this repo as from owslib hasn't changed in years. So I'm completely lost.

edelater commented 1 year ago

@sneuvonen I’ve managed to get csw harvesting working with an older version (tag v1.1.0). So something probably did change somewhere.

rhodges commented 1 year ago

In Feb 2021 OWSLib added support for CSW3, and in chaning the code to support both, brought in non-backward-compatible code changes.

The easy fix: pip install "OWSLib==0.23.0"

The more involved fix would be to use the latest OWSLib and find all places where updates need to be made. I have found the first, but since I don't have it working (nor the time to track them all down) I won't have a PR anytime soon. 1. In ckanext/spatial/lib/csw_client.py class CswService Line 68, replace from owslib.csw import CatalogueServiceWeb as _Implementation with from owslib.catalogue.csw2 import CatalogueServiceWeb as _Implementation