<div dir="ltr">Hi, this is likely to be a bug. Could you file it in the issue tracker? <a href="https://github.com/GeoNode/geonode/issues">https://github.com/GeoNode/geonode/issues</a>.<div><br></div><div>thanks</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-09-26 17:51 GMT+02:00 Gavin Reich <span dir="ltr"><<a href="mailto:Gavin.Reich@michaelcarder.co.uk" target="_blank">Gavin.Reich@michaelcarder.co.uk</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-GB" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal">Hi all,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’m encountering an error related to Hierarchical Keywords when trying to add a layer to geonode using file_upload(). The h_keyword (“human health”) has already been added previously when adding another layer. I’m not sure if this is a
bug in _HierarchicalTagManager.add()? <a href="https://github.com/GeoNode/geonode/blob/master/geonode/base/models.py#L276" target="_blank">
https://github.com/GeoNode/<wbr>geonode/blob/master/geonode/<wbr>base/models.py#L276</a> <u></u>
<u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Any help would be appreciated<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks<u></u><u></u></p>
<p class="MsoNormal">Gavin<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">>>> layer = file_upload(filename='/home/<wbr>ec2-user/test/ospar_<wbr>encounters_2012_01.shp', name='Encounters2012', user=ospar, abstract='encounters 2012 test', overwrite=True, metadata_uploaded_preserve=<wbr>True)<u></u><u></u></p>
<p class="MsoNormal">Traceback (most recent call last):<u></u><u></u></p>
<p class="MsoNormal"> File "<console>", line 1, in <module><u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/src/<wbr>geonode/geonode/layers/utils.<wbr>py", line 514, in file_upload<u></u><u></u></p>
<p class="MsoNormal"> layer.keywords.add(*keywords)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/src/<wbr>geonode/geonode/base/models.<wbr>py", line 291, in add<u></u><u></u></p>
<p class="MsoNormal"> tag_objs.add(<wbr>HierarchicalKeyword.add_root(<wbr>name=new_tag))<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>treebeard/mp_tree.py", line 593, in add_root<u></u><u></u></p>
<p class="MsoNormal"> return MP_AddRootHandler(cls, **kwargs).process()<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>treebeard/mp_tree.py", line 295, in process<u></u><u></u></p>
<p class="MsoNormal"> return last_root.add_sibling('sorted-<wbr>sibling', **self.kwargs)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>treebeard/mp_tree.py", line 982, in add_sibling<u></u><u></u></p>
<p class="MsoNormal"> return MP_AddSiblingHandler(self, pos, **kwargs).process()<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>treebeard/mp_tree.py", line 420, in process<u></u><u></u></p>
<p class="MsoNormal"> newobj.save()<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>taggit/models.py", line 86, in save<u></u><u></u></p>
<p class="MsoNormal"> return super(TagBase, self).save(*args, **kwargs)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/models/base.py", line 734, in save<u></u><u></u></p>
<p class="MsoNormal"> force_update=force_update, update_fields=update_fields)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/models/base.py", line 762, in save_base<u></u><u></u></p>
<p class="MsoNormal"> updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/models/base.py", line 846, in _save_table<u></u><u></u></p>
<p class="MsoNormal"> result = self._do_insert(cls._base_<wbr>manager, using, fields, update_pk, raw)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/models/base.py", line 885, in _do_insert<u></u><u></u></p>
<p class="MsoNormal"> using=using, raw=raw)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/models/manager.py", line 127, in manager_method<u></u><u></u></p>
<p class="MsoNormal"> return getattr(self.get_queryset(), name)(*args, **kwargs)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/models/query.py", line 920, in _insert<u></u><u></u></p>
<p class="MsoNormal"> return query.get_compiler(using=<wbr>using).execute_sql(return_id)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/models/sql/compiler.<wbr>py", line 974, in execute_sql<u></u><u></u></p>
<p class="MsoNormal"> cursor.execute(sql, params)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/backends/utils.py", line 79, in execute<u></u><u></u></p>
<p class="MsoNormal"> return super(CursorDebugWrapper, self).execute(sql, params)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/backends/utils.py", line 64, in execute<u></u><u></u></p>
<p class="MsoNormal"> return self.cursor.execute(sql, params)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/utils.py", line 98, in __exit__<u></u><u></u></p>
<p class="MsoNormal"> six.reraise(dj_exc_type, dj_exc_value, traceback)<u></u><u></u></p>
<p class="MsoNormal"> File "/opt/python/run/venv/local/<wbr>lib/python2.7/site-packages/<wbr>django/db/backends/utils.py", line 64, in execute<u></u><u></u></p>
<p class="MsoNormal"> return self.cursor.execute(sql, params)<u></u><u></u></p>
<p class="MsoNormal">IntegrityError: duplicate key value violates unique constraint "base_hierarchicalkeyword_<wbr>name_key"<u></u><u></u></p>
<p class="MsoNormal">DETAIL: Key (name)=(human health) already exists.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The snippet of the xml metadata containing the keywords:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><gmd:descriptiveKeywords><u></u><u></u></p>
<p class="MsoNormal"><gmd:MD_Keywords><u></u><u></u></p>
<p class="MsoNormal"><gmd:keyword><u></u><u></u></p>
<p class="MsoNormal"><gco:CharacterString>Human health and safety</gco:CharacterString><u></u><u></u></p>
<p class="MsoNormal"></gmd:keyword><u></u><u></u></p>
<p class="MsoNormal"><gmd:thesaurusName><u></u><u></u></p>
<p class="MsoNormal"><gmd:CI_Citation><u></u><u></u></p>
<p class="MsoNormal"><gmd:title><u></u><u></u></p>
<p class="MsoNormal"><gco:CharacterString>GEMET - INSPIRE themes, version 1.0</gco:CharacterString><u></u><u></u></p>
<p class="MsoNormal"></gmd:title><u></u><u></u></p>
<p class="MsoNormal"><gmd:date><u></u><u></u></p>
<p class="MsoNormal"><gmd:CI_Date><u></u><u></u></p>
<p class="MsoNormal"><gmd:date><u></u><u></u></p>
<p class="MsoNormal"><gco:Date>2010-01-13</gco:<wbr>Date><u></u><u></u></p>
<p class="MsoNormal"></gmd:date><u></u><u></u></p>
<p class="MsoNormal"><gmd:dateType><u></u><u></u></p>
<p class="MsoNormal"><gmd:CI_DateTypeCode codeList="<a href="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" target="_blank">http://standards.<wbr>iso.org/ittf/<wbr>PubliclyAvailableStandards/<wbr>ISO_19139_Schemas/resources/<wbr>Codelist/ML_gmxCodelists.xml#<wbr>CI_DateTypeCode</a>" codeListValue="publication"><wbr>publication</gmd:CI_<wbr>DateTypeCode><u></u><u></u></p>
<p class="MsoNormal"></gmd:dateType><u></u><u></u></p>
<p class="MsoNormal"></gmd:CI_Date><u></u><u></u></p>
<p class="MsoNormal"></gmd:date><u></u><u></u></p>
<p class="MsoNormal"></gmd:CI_Citation><u></u><u></u></p>
<p class="MsoNormal"></gmd:thesaurusName><u></u><u></u></p>
<p class="MsoNormal"></gmd:MD_Keywords><u></u><u></u></p>
<p class="MsoNormal"></gmd:descriptiveKeywords><u></u><u></u></p>
<p class="MsoNormal"><gmd:descriptiveKeywords><u></u><u></u></p>
<p class="MsoNormal"><gmd:MD_Keywords><u></u><u></u></p>
<p class="MsoNormal"><gmd:keyword><u></u><u></u></p>
<p class="MsoNormal"><gco:CharacterString>human health</gco:CharacterString><u></u><u></u></p>
<p class="MsoNormal"></gmd:keyword><u></u><u></u></p>
<p class="MsoNormal"><gmd:thesaurusName><u></u><u></u></p>
<p class="MsoNormal"><gmd:CI_Citation><u></u><u></u></p>
<p class="MsoNormal"><gmd:title><u></u><u></u></p>
<p class="MsoNormal"><gco:CharacterString>GEMET - Themes, version 2.4</gco:CharacterString><u></u><u></u></p>
<p class="MsoNormal"></gmd:title><u></u><u></u></p>
<p class="MsoNormal"><gmd:date><u></u><u></u></p>
<p class="MsoNormal"><gmd:CI_Date><u></u><u></u></p>
<p class="MsoNormal"><gmd:date><u></u><u></u></p>
<p class="MsoNormal"><gco:Date>2010-01-13</gco:<wbr>Date><u></u><u></u></p>
<p class="MsoNormal"></gmd:date><u></u><u></u></p>
<p class="MsoNormal"><gmd:dateType><u></u><u></u></p>
<p class="MsoNormal"><gmd:CI_DateTypeCode codeList="<a href="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" target="_blank">http://standards.<wbr>iso.org/ittf/<wbr>PubliclyAvailableStandards/<wbr>ISO_19139_Schemas/resources/<wbr>Codelist/ML_gmxCodelists.xml#<wbr>CI_DateTypeCode</a>" codeListValue="publication"><wbr>publication</gmd:CI_<wbr>DateTypeCode><u></u><u></u></p>
<p class="MsoNormal"></gmd:dateType><u></u><u></u></p>
<p class="MsoNormal"></gmd:CI_Date><u></u><u></u></p>
<p class="MsoNormal"></gmd:date><u></u><u></u></p>
<p class="MsoNormal"></gmd:CI_Citation><u></u><u></u></p>
<p class="MsoNormal"></gmd:thesaurusName><u></u><u></u></p>
<p class="MsoNormal"></gmd:MD_Keywords><u></u><u></u></p>
<p class="MsoNormal"></gmd:descriptiveKeywords><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<br>______________________________<wbr>_________________<br>
geonode-users mailing list<br>
<a href="mailto:geonode-users@lists.osgeo.org">geonode-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/geonode-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/geonode-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Simone </div>
</div>