[ckan-changes] commit/ckan: kindly: [api] let None through as value to fix rest api
Bitbucket
commits-noreply at bitbucket.org
Thu Jul 7 19:03:48 UTC 2011
1 new changeset in ckan:
http://bitbucket.org/okfn/ckan/changeset/a55a42c5cff3/
changeset: a55a42c5cff3
branch: defect-1214-api-improvements
user: kindly
date: 2011-07-07 21:03:18
summary: [api] let None through as value to fix rest api
affected #: 3 files (90 bytes)
--- a/ckan/lib/dictization/model_save.py Thu Jul 07 18:32:12 2011 +0100
+++ b/ckan/lib/dictization/model_save.py Thu Jul 07 20:03:18 2011 +0100
@@ -67,9 +67,6 @@
def package_extras_save(extra_dicts, obj, context):
- allow_partial_update = context.get("allow_partial_update", False)
- if not extra_dicts and allow_partial_update:
- return
model = context["model"]
session = context["session"]
@@ -81,7 +78,10 @@
for extra_dict in extra_dicts:
if extra_dict.get("deleted"):
continue
- if extras_as_string:
+
+ if extra_dict['value'] is None:
+ pass
+ elif extras_as_string:
new_extras[extra_dict["key"]] = extra_dict["value"]
else:
new_extras[extra_dict["key"]] = json.loads(extra_dict["value"])
@@ -318,10 +318,15 @@
updated_extras.update(value)
new_value = []
+
for extras_key, extras_value in updated_extras.iteritems():
if extras_value is not None:
new_value.append({"key": extras_key,
"value": json.dumps(extras_value)})
+ else:
+ new_value.append({"key": extras_key,
+ "value": None})
+
dictized[key] = new_value
groups = dictized.pop('groups', None)
--- a/ckan/logic/schema.py Thu Jul 07 18:32:12 2011 +0100
+++ b/ckan/logic/schema.py Thu Jul 07 20:03:18 2011 +0100
@@ -167,7 +167,7 @@
schema = {
'id': [ignore],
'key': [not_empty, unicode],
- 'value': [not_missing, unicode],
+ 'value': [not_missing],
'state': [ignore],
'deleted': [ignore_missing],
'revision_timestamp': [ignore],
--- a/ckan/tests/functional/api/model/test_package.py Thu Jul 07 18:32:12 2011 +0100
+++ b/ckan/tests/functional/api/model/test_package.py Thu Jul 07 20:03:18 2011 +0100
@@ -367,7 +367,7 @@
self.remove()
package = self.get_package_by_name(new_fixture_data['name'])
# - title
- self.assert_equal(package.extras, [])
+ self.assert_equal(package.extras, {})
def test_package_update_do_not_delete_last_extra(self):
old_fixture_data = {
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