コード例 #1
0
    def refresh_layers(self,save=True):
        result = None
        #modify the table data
        now = timezone.now()
        if self.user and self.user.strip():
            res = requests.get(self.get_capability_url, auth=(self.user,self.password), verify=False)
        else:
            res = requests.get(self.get_capability_url, verify=False)
        res.raise_for_status()
        xml_data = res.text.encode('utf-8')
        root = ElementTree.fromstring(xml_data)
        first_level_layer = root.find("Capability/Layer")
        with transaction.atomic():
            layer_size = self._process_layer_xml(first_level_layer,now)
                    
            if layer_size == 0:
                #no layers found in the server
                #delete all layers
                WmsLayer.objects.filter(server=self).delete()
            else:
                #set status to DELETE for layers not returned from server
                WmsLayer.objects.filter(server=self).exclude(last_refresh_time = now).delete()

            self.layers = layer_size
            self.last_refresh_time = now
            if save:
                self.save()
        refresh_select_choices.send(self,choice_family="wmslayer")
コード例 #2
0
    def refresh_layers(self):
        result = None
        #modify the table data
        now = timezone.now()
        if self.user:
            res = requests.get(self.get_capability_url, auth=(self.user,self.password), verify=False)
        else:
            res = requests.get(self.get_capability_url, verify=False)
        res.raise_for_status()
        #import ipdb;ipdb.set_trace()
        xml_data = res.text.encode('utf-8')
        root = ElementTree.fromstring(xml_data)
        first_level_layer = root.find("Capability/Layer")
        with transaction.atomic():
            layer_size = self._process_layer_xml(first_level_layer,now)
                    
            if layer_size == 0:
                #no layers found in the server
                #delete all layers which is not published or unpublished or remove
                WmsLayer.objects.filter(server=self).delete()
            else:
                #set status to DELETE for layers not returned from server
                WmsLayer.objects.filter(server=self).exclude(last_refresh_time = now).delete()

            self.layers = layer_size
            self.last_refresh_time = now
            self.save()
        refresh_select_choices.send(self,choice_family="wmslayer")
コード例 #3
0
    def _post_save(sender, instance, **args):
        if (hasattr(instance,"new_object") and getattr(instance,"new_object")):
            delattr(instance,"new_object")
            refresh_select_choices.send(instance,choice_family="layergroup")

        if (hasattr(instance,"related_publish") and getattr(instance,"related_publish")):
            delattr(instance,"related_publish")
            for layer in instance.subgroup_layer.all():
                target_status = layer.group.next_status(ResourceAction.CASCADE_PUBLISH)
                if target_status != layer.group.status or layer.group.publish_required:
                    layer.group.status = target_status
                    layer.group.save(update_fields=["status","last_publish_time","last_unpublish_time"])
コード例 #4
0
    def _post_save(sender, instance, **args):
        if (hasattr(instance,"related_publish") and getattr(instance,"related_publish")):
            delattr(instance,"related_publish")
            from layergroup.models import LayerGroupLayers
            for layer in LayerGroupLayers.objects.filter(layer = instance):
                target_status = layer.group.next_status(ResourceAction.CASCADE_PUBLISH)
                if target_status != layer.group.status or layer.group.publish_required:
                    layer.group.status = target_status
                    layer.group.save(update_fields=["status","last_publish_time","last_unpublish_time"])

        if (hasattr(instance,"refresh_select_options") and getattr(instance,"refresh_select_options")):
            delattr(instance,"refresh_select_options")
            refresh_select_choices.send(instance,choice_family="interested_wmslayer")
コード例 #5
0
    def _post_save(sender, instance, **args):
        if (hasattr(instance,"new_object") and getattr(instance,"new_object")):
            delattr(instance,"new_object")
            refresh_select_choices.send(instance,choice_family="layergroup")

        if "update_fields" in args and args['update_fields'] and "status" in args["update_fields"]:
            if instance.status in [ResourceStatus.PUBLISHED,ResourceStatus.UNPUBLISHED]:
                if (hasattr(instance,"side_publish") and getattr(instance,"side_publish")):
                    delattr(instance,"side_publish")
                    for layer in LayerGroupLayers.objects.filter(sub_group = instance):
                        target_status = layer.group.get_next_status(layer.group.status,ResourceStatus.SIDE_PUBLISH)
                        if target_status != layer.group.status:
                            layer.group.status = target_status
                            layer.group.save(update_fields=["status","last_publish_time","last_unpublish_time"])
コード例 #6
0
    def _post_save(sender, instance, **args):
        if (hasattr(instance, "new_object")
                and getattr(instance, "new_object")):
            delattr(instance, "new_object")
            refresh_select_choices.send(instance, choice_family="layergroup")

        if (hasattr(instance, "related_publish")
                and getattr(instance, "related_publish")):
            delattr(instance, "related_publish")
            for layer in instance.subgroup_layer.all():
                target_status = layer.group.next_status(
                    ResourceAction.CASCADE_PUBLISH)
                if target_status != layer.group.status or layer.group.publish_required:
                    layer.group.status = target_status
                    layer.group.save(update_fields=[
                        "status", "last_publish_time", "last_unpublish_time"
                    ])
コード例 #7
0
    def _post_save(sender, instance, **args):
        if (hasattr(instance, "related_publish")
                and getattr(instance, "related_publish")):
            delattr(instance, "related_publish")
            from layergroup.models import LayerGroupLayers
            for layer in LayerGroupLayers.objects.filter(layer=instance):
                target_status = layer.group.next_status(
                    ResourceAction.CASCADE_PUBLISH)
                if target_status != layer.group.status or layer.group.publish_required:
                    layer.group.status = target_status
                    layer.group.save(update_fields=[
                        "status", "last_publish_time", "last_unpublish_time"
                    ])

        if (hasattr(instance, "refresh_select_options")
                and getattr(instance, "refresh_select_options")):
            delattr(instance, "refresh_select_options")
            refresh_select_choices.send(instance,
                                        choice_family="interested_wmslayer")
コード例 #8
0
    def refresh_layers(self, save=True):
        result = None
        #modify the table data
        now = timezone.now()
        if self.user and self.user.strip():
            res = requests.get(self.get_capability_url,
                               auth=(self.user, self.password),
                               verify=False)
        else:
            res = requests.get(self.get_capability_url, verify=False)
        res.raise_for_status()
        if self.wms_version == "1.1.1":
            namespace = ""
        elif self.wms_version == "1.3.0":
            namespace = "{http://www.opengis.net/wms}"
        else:
            raise Exception("Only support wms version 1.1.1 and 1.3.0")
        xml_data = res.text.encode('utf-8')
        root = ElementTree.fromstring(xml_data)
        first_level_layer = root.find(
            "{0}Capability/{0}Layer".format(namespace))
        with transaction.atomic():
            layer_size = self._process_layer_xml(namespace, first_level_layer,
                                                 now)

            if layer_size == 0:
                #no layers found in the server
                #delete all layers
                WmsLayer.objects.filter(server=self).delete()
            else:
                #set status to DELETE for layers not returned from server
                WmsLayer.objects.filter(server=self).exclude(
                    last_refresh_time=now).delete()

            self.layers = layer_size
            self.last_refresh_time = now
            if save:
                self.save()
        refresh_select_choices.send(self, choice_family="wmslayer")
コード例 #9
0
 def _post_delete(sender, instance, **args):
     refresh_select_choices.send(instance, choice_family="layergroup")
コード例 #10
0
 def _post_delete(sender, instance, **args):
     if instance.status != ResourceStatus.New.name:
         refresh_select_choices.send(instance,choice_family="interested_wmslayer")
コード例 #11
0
ファイル: models.py プロジェクト: scottp-dpaw/borgcollector
 def _post_delete(sender, instance, **args):
     refresh_select_choices.send(instance,choice_family="layergroup")
コード例 #12
0
 def _post_delete(sender, instance, **args):
     if instance.status != ResourceStatus.New.name:
         refresh_select_choices.send(instance,
                                     choice_family="interested_wmslayer")