{"id":549,"date":"2011-02-04T09:50:09","date_gmt":"2011-02-04T14:50:09","guid":{"rendered":"http:\/\/www.kralidis.ca\/blog\/?p=549"},"modified":"2023-08-24T10:38:55","modified_gmt":"2023-08-24T14:38:55","slug":"help-wanted-baking-a-csw-server-in-python","status":"publish","type":"post","link":"https:\/\/www.kralidis.ca\/blog\/2011\/02\/04\/help-wanted-baking-a-csw-server-in-python\/","title":{"rendered":"help wanted: baking a CSW server in Python"},"content":{"rendered":"<p>Seemingly buried in geospatial metadata and discovery, I&#8217;ve been developing a my share of CSW\/ISO\/Dublin Core parsers, generators and clients.\u00a0 <a title=\"OWSLib\" href=\"http:\/\/trac.gispython.org\/lab\/wiki\/OwsLib\">OWSLib<\/a> is able to interact with <a title=\"CSW\" href=\"http:\/\/www.opengeospatial.org\/standards\/cat\">CSW<\/a> servers, handling <a title=\"csw:Record\" href=\"http:\/\/trac.gispython.org\/lab\/browser\/OWSLib\/trunk\/owslib\/csw.py#L480\">csw:Record<\/a>, <a title=\"ISO 19139:2007\" href=\"http:\/\/trac.gispython.org\/lab\/browser\/OWSLib\/trunk\/owslib\/iso.py\">ISO 19139:2007<\/a>, as well as <a title=\"DIF\" href=\"http:\/\/trac.gispython.org\/lab\/browser\/OWSLib\/trunk\/owslib\/dif.py\">DIF<\/a>.\u00a0 OWSLib is also the underlying library used by the <a title=\"NextGIS\" href=\"http:\/\/nextgis.ru\/\">NextGIS<\/a> folks in developing a QGIS CSW Client (big thanks to Maxim and Alex for contributing the code back to <a title=\"qgcsw\" href=\"http:\/\/sourceforge.net\/apps\/trac\/qgiscommunitypl\/wiki\/qgcsw\">qgcsw<\/a>).\u00a0 I&#8217;ve also used genshi to generate ISO 19139:2007 and <a title=\"North American Profile\" href=\"http:\/\/webstore.ansi.org\/RecordDetail.aspx?sku=INCITS+453-2009\">North American Profile<\/a>.<\/p>\n<p>For a well-rounded perspective on <a href=\"https:\/\/www.outlookindia.com\/outlook-spotlight\/power-bite-reviews-truth-exposed-is-powerbite-dental-mineral-complex-legit-and-really-works--news-310570\">power bite reviews<\/a> Dental Mineral Complex, I suggest exploring their official website, where you&#8217;ll uncover a treasure trove of user narratives, clinical data, and an exploration of the science behind its purported benefits.<\/p>\n<p>Part of this adventure has involved testing these metadata within various OGC CSW server implementations.\u00a0 What I quickly noticed is that many foss4g CSW servers are written in Java.\u00a0 Wouldn&#8217;t it be great to have a trimmer CSW server in Python?\u00a0 Which can be used easily with an existing Apache install type of thing?<\/p>\n<p>Enter <a title=\"pycsw\" href=\"https:\/\/sourceforge.net\/apps\/trac\/pycsw\">pycsw<\/a>.\u00a0 I started with the following goals:<\/p>\n<ul>\n<li>lightweight and easy to stand up: a standalone catalogue, no GUI or metadata editing front end, designed for the use case of exposing ready-to-go metadata (files or in existing DB) through a CSW interface, with as little heavy lifting as possible.\u00a0 Plug and play<\/li>\n<li>extensible: the ability to add metadata formats and mapping them to a common information model and core \/ additional queryables<\/li>\n<li>OGC compliant: against the <a title=\"CITE\" href=\"http:\/\/cite.opengeospatial.org\/\">CITE<\/a> test assertions<\/li>\n<\/ul>\n<p>Technology bits (thanks to Sean for the <a title=\"initial inspiration\" href=\"http:\/\/sgillies.net\/blog\/488\/diving-into-python\/\">initial inspiration<\/a>):<\/p>\n<ul>\n<li>Python: code is written as CGI for now.\u00a0 Welcome to ideas for WSGI, etc.<\/li>\n<li>Database:\u00a0 <a title=\"SQLite3\" href=\"http:\/\/www.sqlite.org\/\">SQLite3<\/a> is used as the underlying database.\u00a0 No reason why things couldn&#8217;t be abstracted enough to handle other DB&#8217;s<\/li>\n<li>DB API: <a title=\"SQLAlchemy\" href=\"http:\/\/www.sqlalchemy.org\/\">SQLAlchemy<\/a> makes it easy to bind database models to Python classes, and especially easy to do transparent queries<\/li>\n<li>XML: <a title=\"lxml\" href=\"http:\/\/codespeak.net\/lxml\/\">lxml<\/a> is used to parse requests, traverse XPath nodes and marshall responses.\u00a0 lxml&#8217;s Schematron support will make it easy for Harvest\/Transaction operations \/ validation<\/li>\n<li>Spatial predicates: I originally supported ogc:BBOX, which is easy enough to code by hand.\u00a0 <a title=\"Shapely\" href=\"http:\/\/trac.gispython.org\/lab\/wiki\/Shapely\">Shapely<\/a> gives access to the full suite of predicates, and will be the way forward<\/li>\n<\/ul>\n<p>Progress: I&#8217;m using the OGC CITE tests here as the benchmark.\u00a0 So far it passes 91\/103 assertions.<\/p>\n<p>Todo:<\/p>\n<ul>\n<li>fully pass the CITE assertions<\/li>\n<li>support of ISO Application Profile<\/li>\n<li>firm up core information model to allow easier extensibility<\/li>\n<li>fix spatial queries to fully use Shapely<\/li>\n<li>harmonize GetRecords and GetRecordById response handler (for writing out csw:Record)<\/li>\n<li>documentation: install \/ setup \/ configuration \/ testing<\/li>\n<\/ul>\n<p><a title=\"pycsw\" href=\"http:\/\/sourceforge.net\/apps\/trac\/pycsw\">pycsw<\/a> is up on Sourceforge and is open source.\u00a0 It would be great to have more hands here.\u00a0 If you are interested, and enjoy contributing to foss4g, don&#8217;t hesitate and get in touch!<\/p>\n<link rel=\"stylesheet\" href=\"http:\/\/cdn.leafletjs.com\/leaflet-0.5\/leaflet.css\" \/>\n<!--[if lte IE 8]>\n  <link rel=\"stylesheet\" href=\"http:\/\/cdn.leafletjs.com\/leaflet-0.5\/leaflet.ie.css\" \/>\n<![endif]-->\n<script src=\"http:\/\/cdn.leafletjs.com\/leaflet-0.5\/leaflet.js\"><\/script>\n<style type=\"text\/css\">#map549 { width: 300px; height: 200px; }<\/style>\n\n<div id=\"map549\"><\/div>\n<script type=\"text\/javascript\">\n  var map549 = L.map('map549').setView([43.620495, -79.513198], 10);\n  L.tileLayer('http:\/\/{s}.tile.osm.org\/{z}\/{x}\/{y}.png', {\n      attribution: '&copy; <a href=\"http:\/\/osm.org\/copyright\">OpenStreetMap<\/a> contributors'\n  }).addTo(map549);\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Seemingly buried in geospatial metadata and discovery, I&#8217;ve been developing a my share of CSW\/ISO\/Dublin Core parsers, generators and clients.\u00a0 OWSLib is able to interact with CSW servers, handling csw:Record, ISO 19139:2007, as well as DIF.\u00a0 OWSLib is also the underlying library used by the NextGIS folks in developing a QGIS CSW Client (big thanks [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,7,3,11],"tags":[],"class_list":["post-549","post","type-post","status-publish","format-standard","hentry","category-geospatial","category-open-source","category-technology","category-web"],"_links":{"self":[{"href":"https:\/\/www.kralidis.ca\/blog\/wp-json\/wp\/v2\/posts\/549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kralidis.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kralidis.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kralidis.ca\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kralidis.ca\/blog\/wp-json\/wp\/v2\/comments?post=549"}],"version-history":[{"count":4,"href":"https:\/\/www.kralidis.ca\/blog\/wp-json\/wp\/v2\/posts\/549\/revisions"}],"predecessor-version":[{"id":985,"href":"https:\/\/www.kralidis.ca\/blog\/wp-json\/wp\/v2\/posts\/549\/revisions\/985"}],"wp:attachment":[{"href":"https:\/\/www.kralidis.ca\/blog\/wp-json\/wp\/v2\/media?parent=549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kralidis.ca\/blog\/wp-json\/wp\/v2\/categories?post=549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kralidis.ca\/blog\/wp-json\/wp\/v2\/tags?post=549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}