def delete(self, *args, **kwargs): from wirecloud.catalogue.utils import wgt_deployer # Delete the related wiring information for that resource WidgetWiring.objects.filter(idResource=self.id).delete() # Delete the related tags for that resource UserTag.objects.filter(idResource=self.id).delete() # Delete the related votes for that resource UserVote.objects.filter(idResource=self.id).delete() if hasattr(self, 'widget'): from wirecloud.platform.models import Widget try: self.widget.delete() except Widget.DoesNotExist: pass # Delete media resources if needed if not self.template_uri.startswith(('http', 'https')): wgt_deployer.undeploy(self.vendor, self.short_name, self.version) super(CatalogueResource, self).delete(*args, **kwargs)
def delete(self, *args, **kwargs): from wirecloud.catalogue.utils import wgt_deployer old_id = self.id super(CatalogueResource, self).delete(*args, **kwargs) # Preserve the id attribute a bit more so CatalogueResource methods can use it self.id = old_id # Undeploy the resource from the filesystem try: wgt_deployer.undeploy(self.vendor, self.short_name, self.version) except: # TODO log this error pass # ignore errors # Remove cache for this resource self.invalidate_cache() # Remove document from search indexes try: with get_search_engine('resource').get_batch_writer() as writer: writer.delete_by_term('pk', '%s' % old_id) except: pass # ignore errors # Remove id attribute definetly self.id = None
def delete(self, *args, **kwargs): from wirecloud.catalogue.utils import wgt_deployer # Delete the related wiring information for that resource WidgetWiring.objects.filter(idResource=self.id).delete() if hasattr(self, 'widget'): from wirecloud.platform.models import Widget try: self.widget.delete() except Widget.DoesNotExist: pass # Delete media resources if needed if not self.template_uri.startswith(('http', 'https')): wgt_deployer.undeploy(self.vendor, self.short_name, self.version) old_id = self.id super(CatalogueResource, self).delete(*args, **kwargs) # Remove cache for this resource try: cache.incr('_catalogue_resource_version/' + str(old_id)) except ValueError: pass
def delete_file_on_resource_deletion(sender, instance, **kwargs): # Undeploy the resource from the filesystem try: wgt_deployer.undeploy(instance.vendor, instance.short_name, instance.version) except Exception: # TODO log this error pass # ignore errors instance.invalidate_cache()
def delete(self, *args, **kwargs): from wirecloud.catalogue.utils import wgt_deployer old_id = self.id super(CatalogueResource, self).delete(*args, **kwargs) # Preserve the id attribute a bit more so CatalogueResource methods can use it self.id = old_id # Undeploy the resource from the filesystem try: wgt_deployer.undeploy(self.vendor, self.short_name, self.version) except: # TODO log this error pass # ignore errors # Remove cache for this resource self.invalidate_cache() # Remove id attribute definetly self.id = None