[ckan-changes] commit/ckan: kindly: put url change in the same place as domain object modification
Bitbucket
commits-noreply at bitbucket.org
Tue Oct 18 13:56:25 UTC 2011
1 new changeset in ckan:
http://bitbucket.org/okfn/ckan/changeset/778afb37e876/
changeset: 778afb37e876
branch: feature-1371-task-status-logic-layer
user: kindly
date: 2011-10-18 15:56:03
summary: put url change in the same place as domain object modification
affected #: 2 files (-1 bytes)
--- a/ckan/lib/dictization/model_save.py Mon Oct 17 19:25:12 2011 +0100
+++ b/ckan/lib/dictization/model_save.py Tue Oct 18 14:56:03 2011 +0100
@@ -1,8 +1,6 @@
from ckan.lib.dictization import table_dict_save
from sqlalchemy.orm import class_mapper
from ckan.lib.helpers import json
-from ckan.plugins import (PluginImplementations,
- IResourceUrlChange)
##package saving
@@ -33,7 +31,7 @@
continue
if key in fields:
if key == 'url' and not new and obj.url <> value:
- trigger_url_change = True
+ obj.url_changed = True
setattr(obj, key, value)
else:
# resources save extras directly onto the object, instead
@@ -46,10 +44,6 @@
else:
obj.state = u'active'
- if trigger_url_change:
- for item in PluginImplementations(IResourceUrlChange):
- item.notify(obj)
-
session.add(obj)
return obj
--- a/ckan/model/modification.py Mon Oct 17 19:25:12 2011 +0100
+++ b/ckan/model/modification.py Tue Oct 18 14:56:03 2011 +0100
@@ -6,7 +6,7 @@
from sqlalchemy.orm.interfaces import EXT_CONTINUE
from ckan.plugins import SingletonPlugin, PluginImplementations, implements
-from ckan.plugins import ISession, IDomainObjectModification
+from ckan.plugins import ISession, IDomainObjectModification, IResourceUrlChange
from ckan.model.extension import ObserverNotifier
from ckan.model.domain_object import DomainObjectOperation
@@ -49,6 +49,9 @@
for obj in changed:
if isinstance(obj, Resource):
self.notify(obj, DomainObjectOperation.changed)
+ if getattr(obj, 'url_changed', False):
+ for item in PluginImplementations(IResourceUrlChange):
+ item.notify(obj)
changed_pkgs = set(obj for obj in changed if isinstance(obj, Package))
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list