[ckan-changes] commit/ckan: kindly: fix errors with resource save

Bitbucket commits-noreply at bitbucket.org
Thu Oct 27 11:28:20 UTC 2011


1 new commit in ckan:


https://bitbucket.org/okfn/ckan/changeset/fbdc6eb0a650/
changeset:   fbdc6eb0a650
branch:      feature-1371-task-status-logic-layer
user:        kindly
date:        2011-10-27 13:27:39
summary:     fix errors with resource save
affected #:  5 files

diff -r d47743b7cc27c630b22667ca512d354e06a50286 -r fbdc6eb0a6504755f82a8e039e7873017dd6d000 ckan/lib/dictization/model_save.py
--- a/ckan/lib/dictization/model_save.py
+++ b/ckan/lib/dictization/model_save.py
@@ -8,12 +8,10 @@
     model = context["model"]
     session = context["session"]
     trigger_url_change = False
-
-    # try to get resource object directly from context, then by ID
-    # if not found, create a new resource object
+    
     id = res_dict.get("id")
-    obj = context.get("resource")
-    if (not obj) and id:
+    obj = None
+    if id:
         obj = session.query(model.Resource).get(id)
     if not obj:
         new = True


diff -r d47743b7cc27c630b22667ca512d354e06a50286 -r fbdc6eb0a6504755f82a8e039e7873017dd6d000 ckan/logic/action/get.py
--- a/ckan/logic/action/get.py
+++ b/ckan/logic/action/get.py
@@ -787,6 +787,8 @@
                           apikey=apikey)
         model.add_user_to_role(user, model.Role.ADMIN, model.System())
         model.Session.add(user)
-        model.Session.commit()
+        model.Session.flush()
+        if not context.get('defer_commit'):
+            model.Session.commit()
     return {'name': user.name,
             'apikey': user.apikey}


diff -r d47743b7cc27c630b22667ca512d354e06a50286 -r fbdc6eb0a6504755f82a8e039e7873017dd6d000 ckan/logic/action/update.py
--- a/ckan/logic/action/update.py
+++ b/ckan/logic/action/update.py
@@ -369,8 +369,6 @@
     user = context['user']
     id = data_dict.get("id")
     schema = context.get('schema') or default_task_status_schema()
-    model.Session.remove()
-    model.Session()._context = context
 
     if id:
         task_status = model.TaskStatus.get(id)


diff -r d47743b7cc27c630b22667ca512d354e06a50286 -r fbdc6eb0a6504755f82a8e039e7873017dd6d000 ckan/model/modification.py
--- a/ckan/model/modification.py
+++ b/ckan/model/modification.py
@@ -40,13 +40,13 @@
         changed = obj_cache['changed']
         deleted = obj_cache['deleted']
 
-        for obj in new:
+        for obj in set(new):
             if isinstance(obj, (Package, Resource)):
                 self.notify(obj, DomainObjectOperation.new)
-        for obj in deleted:
+        for obj in set(deleted):
             if isinstance(obj, (Package, Resource)):
                 self.notify(obj, DomainObjectOperation.deleted)
-        for obj in changed:
+        for obj in set(changed):
             if isinstance(obj, Resource):
                 self.notify(obj, DomainObjectOperation.changed)
             if getattr(obj, 'url_changed', False):


diff -r d47743b7cc27c630b22667ca512d354e06a50286 -r fbdc6eb0a6504755f82a8e039e7873017dd6d000 ckan/tests/functional/api/test_action.py
--- a/ckan/tests/functional/api/test_action.py
+++ b/ckan/tests/functional/api/test_action.py
@@ -547,7 +547,6 @@
 
         resource_updated.pop('url')
         resource_updated.pop('revision_id')
-        resource_updated.pop('revision_timestamp')
         resource_created.pop('url')
         resource_created.pop('revision_id')
         resource_created.pop('revision_timestamp')

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