<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">new idea !<br>
      <br>
      Le 03/05/2016 11:05, Chiarello Ernest a écrit :<br>
    </div>
    <blockquote cite="mid:572869D5.7040602@univ-fcomte.fr" type="cite">
      <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
      <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 moz-do-not-send="true" 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 moz-do-not-send="true" 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 moz-do-not-send="true" 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>
    </blockquote>
    <br>
    I realized that username and password should be send when opening
    CSW !<br>
    <tt>csw = CatalogueServiceWeb(geonetwork, skip_caps=True,
      username='admin', password='admin')</tt><tt><br>
    </tt><br>
    but i have a new error...<br>
    <br>
    <tt>>>> 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>'</tt><tt><br>
    </tt><tt>>>> from owslib.csw import CatalogueServiceWeb</tt><tt><br>
    </tt><tt>>>> csw = CatalogueServiceWeb(geonetwork,
      skip_caps=True, username='admin', password='admin')</tt><tt><br>
    </tt><tt>>>> csw.transaction(ttype='insert',
      typename='gmd:MD_Metadata', record=open('metadata.xml').read())</tt><tt><br>
    </tt><tt>Traceback (most recent call last):</tt><tt><br>
    </tt><tt>  File "<stdin>", line 1, in <module></tt><tt><br>
    </tt><tt>  File "/usr/lib/python2.7/dist-packages/owslib/csw.py",
      line 429, in transaction</tt><tt><br>
    </tt><tt>    node1.append(etree.fromstring(record))</tt><tt><br>
    </tt><tt>  File "src/lxml/lxml.etree.pyx", line 3213, in
      lxml.etree.fromstring (src/lxml/lxml.etree.c:82934)</tt><tt><br>
    </tt><tt>  File "src/lxml/parser.pxi", line 1819, in
      lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:124533)</tt><tt><br>
    </tt><tt>  File "src/lxml/parser.pxi", line 1707, in
      lxml.etree._parseDoc (src/lxml/lxml.etree.c:123074)</tt><tt><br>
    </tt><tt>  File "src/lxml/parser.pxi", line 1079, in
      lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:117114)</tt><tt><br>
    </tt><tt>  File "src/lxml/parser.pxi", line 573, in
      lxml.etree._ParserContext._handleParseResultDoc
      (src/lxml/lxml.etree.c:110510)</tt><tt><br>
    </tt><tt>  File "src/lxml/parser.pxi", line 683, in
      lxml.etree._handleParseResult (src/lxml/lxml.etree.c:112276)</tt><tt><br>
    </tt><tt>  File "src/lxml/parser.pxi", line 624, in
      lxml.etree._raiseParseError (src/lxml/lxml.etree.c:111367)</tt><tt><br>
    </tt><tt>lxml.etree.XMLSyntaxError: None</tt><tt><br>
    </tt><br>
    any help ?<br>
    <br>
    Ernest.<br>
    <br>
    <blockquote cite="mid:572869D5.7040602@univ-fcomte.fr" type="cite">
      <br>
      <blockquote
cite="mid:CAFWXLWWOinYvBVwG3J8D8hgnFueL8L40r9aniYQu90iLq2Cv0Q@mail.gmail.com"
        type="cite">
        <blockquote type="cite">
          <pre wrap="">Thanks in advance,

Ernest.
</pre>
        </blockquote>
      </blockquote>
      <br>
      <br>
      <pre class="moz-signature" cols="72">-- 
Ernest CHIARELLO  -  <a moz-do-not-send="true" 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>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
OWSLib-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OWSLib-users@lists.osgeo.org">OWSLib-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/owslib-users">http://lists.osgeo.org/mailman/listinfo/owslib-users</a></pre>
    </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>