How to perform transactions against GeoNetwork in Python

The attached gn_csw.py python script is an adaptation of  http://lab.usgin.org/groups/etl-debug-blog/geonetwork-authentication-and-csw-transactions-through-python.

It allows to perform simple CSW queries as well as to showcase the process for authenticated transactions, which should always be the case.

Usage

The script works against a GeoNetwork instance located at http://localhost:8080/geonetwork. To change the server URL edit the variable gn_baseURL at the beginning of the script. To change the user credentials to connect with, edit the variables gn_username, and gn_password.

To perform a CQL based query, just type: python gn_csw.py search <CQL query>. For example: python gn_csw.py search "AnyText LIKE '%Africa%'"

To perform a transaction, as they can only be made through HTTP POST, you need an xml file containing the CSW transaction document (such as the attached ones). Then type python gn_csw.py transaction <file>. For example: python gn_csw.py transaction transaction_insert.xml

Similarly, the simple python gn_csw.py getcaps command retrieves the CSW's GetCapabilities document.

---

Back to CSW_sample_requests_and_responses

Attachments