<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi Tom,<br>
<br>
Le 03/05/2016 05:04, Tom Kralidis a écrit :<br>
</div>
<blockquote
cite="mid:CAFWXLWWOinYvBVwG3J8D8hgnFueL8L40r9aniYQu90iLq2Cv0Q@mail.gmail.com"
type="cite">
<pre wrap="">On Mon, May 2, 2016 at 6:12 AM, Chiarello Ernest
<a class="moz-txt-link-rfc2396E" href="mailto:Ernest.Chiarello@univ-fcomte.fr"><Ernest.Chiarello@univ-fcomte.fr></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi all,
I am trying to insert a metadata in GeoNetwork, according OWSlib
documentation but it fails with this error message :
RuntimeError: Document is XML, but not CSW-ish
But above all, i think quotes are missing in the csw transaction. you should
write :
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">csw.transaction(ttype='insert', typename='gmd:MD_Metadata',
record=open("file.xml").read())
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="">instead of :
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">csw.transaction(ttype='insert', typename='gmd:MD_Metadata',
record=open(file.xml).read())
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="">
Next i recovered a file from another GeoNetwork, in order to be sure that
the metadata file would be correct.
wget
<a class="moz-txt-link-freetext" href="https://georchestra-mshe.univ-fcomte.fr/geonetwork/srv/fre/xml.metadata.get?id=17804">https://georchestra-mshe.univ-fcomte.fr/geonetwork/srv/fre/xml.metadata.get?id=17804</a>
-O metadata.xml
And then i tried to insert this metadata in my GeoNetwork Dev machine :
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">geonetwork =
'<a class="moz-txt-link-freetext" href="http://geonetwork-mshe.univ-fcomte.fr:8080/geonetwork/srv/fre/csw">http://geonetwork-mshe.univ-fcomte.fr:8080/geonetwork/srv/fre/csw</a>'
from owslib.csw import CatalogueServiceWeb
csw = CatalogueServiceWeb(geonetwork)
csw.transaction(ttype='insert', typename='gmd:MD_Metadata',
record=open("metadata.xml").read())
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="">Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 446, in
transaction
self._invoke()
File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 680, in
_invoke
raise RuntimeError('Document is XML, but not CSW-ish')
RuntimeError: Document is XML, but not CSW-ish
Can anybody explain to me why my metadata.xml file is not CSW-ish ?
</pre>
</blockquote>
<pre wrap="">
My guess is that some sort of authentication is required to make CSW-T
requests against the CSW in question. Try adding the username an
password parameters to the constructor?
..Tom
</pre>
</blockquote>
sorry, but i do not know how to set username and passord in the csw
transaction.<br>
<br>
<table class="highlight tab-size js-file-line-container"
data-tab-size="8">
<tbody>
<tr>
<td id="LC393" class="blob-code blob-code-inner js-file-line"><span
class="pl-k">def</span> <span class="pl-en">transaction</span>(<span
class="pl-smi"><span class="pl-smi">self</span></span>, <span
class="pl-smi">ttype</span><span class="pl-k">=</span><span
class="pl-c1">None</span>, <span class="pl-smi">typename</span><span
class="pl-k">=</span><span class="pl-s"><span
class="pl-pds">'</span>csw:Record<span class="pl-pds">'</span></span>,
<span class="pl-smi">record</span><span class="pl-k">=</span><span
class="pl-c1">None</span>, <span class="pl-smi">propertyname</span><span
class="pl-k">=</span><span class="pl-c1">None</span>, <span
class="pl-smi">propertyvalue</span><span class="pl-k">=</span><span
class="pl-c1">None</span>, <span class="pl-smi">bbox</span><span
class="pl-k">=</span><span class="pl-c1">None</span>, <span
class="pl-smi">keywords</span><span class="pl-k">=</span>[],
<span class="pl-smi">cql</span><span class="pl-k">=</span><span
class="pl-c1">None</span>, <span class="pl-smi">identifier</span><span
class="pl-k">=</span><span class="pl-c1">None</span>):</td>
</tr>
<tr>
</tr>
</tbody>
</table>
<table class="highlight tab-size js-file-line-container"
data-tab-size="8">
<tbody>
<tr>
</tr>
<tr>
<td id="LC394" class="blob-code blob-code-inner js-file-line">
<span class="pl-s"><span class="pl-pds">"""</span></span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC395" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"></span><br>
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC396" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> Construct and process a Transaction request</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC397" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"></span><br>
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC398" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> Parameters</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC399" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> ----------</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC400" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"></span><br>
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC401" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> - ttype: the type of transaction 'insert,
'update', 'delete'</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC402" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> - typename: the typename to describe
(default is 'csw:Record')</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC403" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> - record: the XML record to insert</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC404" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> - propertyname: the
RecordProperty/PropertyName to Filter against</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC405" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> - propertyvalue: the RecordProperty Value to
Filter against (for updates)</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC406" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> - bbox: the bounding box of the spatial
query in the form [minx,miny,maxx,maxy]</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC407" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> - keywords: list of keywords</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC408" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> - cql: common query language text. Note this
overrides bbox, qtype, keywords</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC409" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"> - identifier: record identifier. Note this
overrides bbox, qtype, keywords, cql</span></td>
</tr>
<tr>
</tr>
</tbody>
</table>
<table class="highlight tab-size js-file-line-container"
data-tab-size="8">
<tbody>
<tr>
<td id="LC410" class="blob-code blob-code-inner js-file-line"><span
class="pl-s"></span><br>
</td>
</tr>
</tbody>
</table>
<br>
thanks for your help,<br>
<br>
<br>
Ernest.<br>
<br>
<br>
<blockquote
cite="mid:CAFWXLWWOinYvBVwG3J8D8hgnFueL8L40r9aniYQu90iLq2Cv0Q@mail.gmail.com"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Thanks in advance,
Ernest.
</pre>
</blockquote>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Ernest CHIARELLO - <a class="moz-txt-link-abbreviated" href="mailto:Ernest.Chiarello@univ-fcomte.fr">Ernest.Chiarello@univ-fcomte.fr</a>
UMR6049 ThéMA - Théoriser et Modéliser pour Aménager
CNRS / université de Bourgogne Franche-Comté
32 rue Mégevand 25030 BESANÇON Cedex
Tel : 03 81 66 54 80 Mob : 07 82 99 11 08
</pre>
</body>
</html>