[GeoNode-users] creating a layer from another django app

Gavin Reich Gavin.Reich at michaelcarder.co.uk
Tue Jul 26 12:40:52 PDT 2016


Hi all,

We're trying to create a layer from within another project.  I was wondering what the best way to do this might be without using importlayers from the cmd line? I just need to take a zipped up shapefile and create a layer from that. I've been trying to use file_upload() from geonode.layers.utils to upload & create the layer but am running into the problem below. All the correct settings are being picked up when I look at django.conf.settings.OGC_SERVER and geonode.geoserver.helpers.ogc_server_settings. (the zip uploads fine into our geonode manually and if I use importlayers).

Am I going about this the wrong way?

Thanks
Gavin

For example:
(geonode) ubuntu at ip-172-31-43-109:/opt/geonode/geonode $ python manage.py shell
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from geonode.layers.utils import file_upload
>>> new_layer = file_upload(filename='/var/www/data_uploads/test_2000_01.zip')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/opt/geonode/geonode/geonode/layers/utils.py", line 481, in file_upload
    defaults=defaults
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/modeltranslation/manager.py", line 389, in get_or_create
    return super(MultilingualQuerySet, self).get_or_create(**kwargs)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/django/db/models/query.py", line 407, in get_or_create
    return self._create_object_from_params(lookup, params)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/django/db/models/query.py", line 439, in _create_object_from_params
    obj = self.create(**params)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/modeltranslation/manager.py", line 381, in create
    return super(MultilingualQuerySet, self).create(**kwargs)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/django/db/models/query.py", line 348, in create
    obj.save(force_insert=True, using=self.db)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/polymorphic/models.py", line 90, in save
    return super(PolymorphicModel, self).save(*args, **kwargs)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/django/db/models/base.py", line 734, in save
    force_update=force_update, update_fields=update_fields)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/django/db/models/base.py", line 771, in save_base
    update_fields=update_fields, raw=raw, using=using)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 189, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/opt/geonode/geonode/geonode/geoserver/signals.py", line 190, in geoserver_post_save
    workspace=instance.workspace)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/geoserver/catalog.py", line 672, in get_resource
    store = self.get_store(store, workspace)
  File "/opt/venv/geonode/local/lib/python2.7/site-packages/geoserver/catalog.py", line 287, in get_store
    raise FailedRequestError("No store found named: " + name)
FailedRequestError: No store found named:
>>>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-users/attachments/20160726/9ed7c55c/attachment.html>


More information about the geonode-users mailing list