Permalink
Browse files

Make sure updatelayers works still

  • Loading branch information...
1 parent ee4b0b6 commit b2714673319844418c5474264715a536baeb5b5f @jj0hns0n jj0hns0n committed Nov 4, 2012
Showing with 15 additions and 5 deletions.
  1. +13 −4 geonode/gs_helpers.py
  2. +2 −1 geonode/layers/management/commands/updatelayers.py
View
@@ -17,13 +17,19 @@
#
#########################################################################
-from itertools import cycle, izip
-from geoserver.catalog import FailedRequestError
+import sys
import logging
import re
import errno
+import uuid
+from itertools import cycle, izip
+
from django.conf import settings
+from geonode.utils import _user, _password
+
+from geoserver.catalog import Catalog, FailedRequestError
+
logger = logging.getLogger("geonode.maps.gs_helpers")
_punc = re.compile(r"[\.:]") #regex for punctuation that confuses restconfig
@@ -220,7 +226,7 @@ def delete_from_postgis(resource_name):
finally:
conn.close()
-def slurp(self, ignore_errors=True, verbosity=1, console=None, owner=None, workspace=None):
+def gs_slurp(self, ignore_errors=True, verbosity=1, console=None, owner=None, workspace=None):
"""Configure the layers available in GeoServer in GeoNode.
It returns a list of dictionaries with the name of the layer,
@@ -231,7 +237,8 @@ def slurp(self, ignore_errors=True, verbosity=1, console=None, owner=None, works
if verbosity > 1:
print >> console, "Inspecting the available layers in GeoServer ..."
- cat = self.gs_catalog
+ url = "%srest" % settings.GEOSERVER_BASE_URL
+ cat = Catalog(url, _user, _password)
if workspace is not None:
workspace = cat.get_workspace(workspace)
resources = cat.get_resources(workspace=workspace)
@@ -245,6 +252,8 @@ def slurp(self, ignore_errors=True, verbosity=1, console=None, owner=None, works
store = resource.store
workspace = store.workspace
try:
+ # Avoid circular import problem
+ from geonode.layers.models import Layer
layer, created = Layer.objects.get_or_create(name=name, defaults = {
"workspace": workspace.name,
"store": store.name,
@@ -21,6 +21,7 @@
from optparse import make_option
from geonode.layers.models import Layer
from geonode.people.utils import get_valid_user
+from geonode.gs_helpers import gs_slurp
import traceback
import datetime
import sys
@@ -53,7 +54,7 @@ def handle(self, **options):
console = None
start = datetime.datetime.now()
- output = Layer.objects.slurp(ignore_errors, verbosity=verbosity,
+ output = gs_slurp(ignore_errors, verbosity=verbosity,
owner=owner, console=console, workspace=workspace)
updated = [dict_['name'] for dict_ in output if dict_['status']=='updated']
created = [dict_['name'] for dict_ in output if dict_['status']=='created']

0 comments on commit b271467

Please sign in to comment.