Skip to content

Commit

Permalink
[#1474] fix resource schema in package show to return None as default
Browse files Browse the repository at this point in the history
Without a default these values, if not provided can return Missing,
which is not jsonable and causes the package/related/api controllers to
404 when they try to dump the json.
  • Loading branch information
joetsoi committed Jan 30, 2014
1 parent e73b580 commit 7b01219
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions ckan/lib/navl/validators.py
Expand Up @@ -65,13 +65,13 @@ def ignore(key, data, errors, context):
value = data.pop(key, None)
raise StopOnError

def default(defalult_value):
def default(default_value):

def callable(key, data, errors, context):

value = data.get(key)
if not value or value is missing:
data[key] = defalult_value
data[key] = default_value

return callable

Expand Down
31 changes: 16 additions & 15 deletions ckan/logic/schema.py
Expand Up @@ -5,7 +5,8 @@
ignore,
if_empty_same_as,
not_missing,
ignore_empty
ignore_empty,
default,
)
from ckan.logic.validators import (package_id_not_changed,
package_id_exists,
Expand Down Expand Up @@ -203,20 +204,20 @@ def default_show_package_schema():
'last_modified': [ckan.lib.navl.validators.ignore_missing],
'cache_last_updated': [ckan.lib.navl.validators.ignore_missing],
'webstore_last_updated': [ckan.lib.navl.validators.ignore_missing],
'revision_timestamp': [],
'resource_group_id': [],
'cache_last_updated': [],
'webstore_last_updated': [],
'size': [],
'state': [],
'last_modified': [],
'mimetype': [],
'cache_url': [],
'name': [],
'webstore_url': [],
'mimetype_inner': [],
'resource_type': [],
'url_type': [],
'revision_timestamp': [default(None)],
'resource_group_id': [default(None)],
'cache_last_updated': [default(None)],
'webstore_last_updated': [default(None)],
'size': [default(None)],
'state': [default(None)],
'last_modified': [default(None)],
'mimetype': [default(None)],
'cache_url': [default(None)],
'name': [default(None)],
'webstore_url': [default(None)],
'mimetype_inner': [default(None)],
'resource_type': [default(None)],
'url_type': [default(None)],
})

schema.update({
Expand Down

0 comments on commit 7b01219

Please sign in to comment.