diff --git a/ckan/model/modification.py b/ckan/model/modification.py index 585d771198b..d8bbcaad665 100644 --- a/ckan/model/modification.py +++ b/ckan/model/modification.py @@ -1,5 +1,7 @@ import logging +from ckan.lib.search import SearchIndexError + import ckan.plugins as plugins import domain_object import package as _package @@ -9,6 +11,7 @@ __all__ = ['DomainObjectModificationExtension'] + class DomainObjectModificationExtension(plugins.SingletonPlugin): """ A domain object level interface to change notifications @@ -30,7 +33,6 @@ def notify_observers(self, func): plugins.IDomainObjectModification): func(observer) - def before_commit(self, session): self.notify_observers(session, self.notify) @@ -60,7 +62,8 @@ def notify_observers(self, session, method): for item in plugins.PluginImplementations(plugins.IResourceUrlChange): item.notify(obj) - changed_pkgs = set(obj for obj in changed if isinstance(obj, _package.Package)) + changed_pkgs = set(obj for obj in changed + if isinstance(obj, _package.Package)) for obj in new | changed | deleted: if not isinstance(obj, _package.Package): @@ -76,25 +79,24 @@ def notify_observers(self, session, method): for obj in changed_pkgs: method(obj, domain_object.DomainObjectOperation.changed) - def notify(self, entity, operation): for observer in plugins.PluginImplementations( plugins.IDomainObjectModification): try: observer.notify(entity, operation) + except SearchIndexError, search_error: + log.exception(search_error) + raise search_error except Exception, ex: log.exception(ex) - # We reraise all exceptions so they are obvious there - # is something wrong - raise def notify_after_commit(self, entity, operation): for observer in plugins.PluginImplementations( plugins.IDomainObjectModification): try: observer.notify_after_commit(entity, operation) + except SearchIndexError, search_error: + log.exception(search_error) + raise search_error except Exception, ex: log.exception(ex) - # We reraise all exceptions so they are obvious there - # is something wrong - raise