CKAN 2.2 documentation » Writing CKAN extensions »

Converter functions reference

ckan.logic.converters.convert_to_extras(key, data, errors, context)
ckan.logic.converters.convert_from_extras(key, data, errors, context)
ckan.logic.converters.date_to_db(value, context)
ckan.logic.converters.date_to_form(value, context)
ckan.logic.converters.free_tags_only(key, data, errors, context)
ckan.logic.converters.convert_to_tags(vocab)
ckan.logic.converters.convert_from_tags(vocab)
ckan.logic.converters.convert_user_name_or_id_to_id(user_name_or_id, context)

Return the user id for the given user name or id.

The point of this function is to convert user names to ids. If you have something that may be a user name or a user id you can pass it into this function and get the user id out either way.

Also validates that a user with the given name or id exists.

Returns:the id of the user with the given user name or id
Return type:string
Raises :ckan.lib.navl.dictization_functions.Invalid if no user can be found with the given id or user name
ckan.logic.converters.convert_package_name_or_id_to_id(package_name_or_id, context)

Return the package id for the given package name or id.

The point of this function is to convert package names to ids. If you have something that may be a package name or id you can pass it into this function and get the id out either way.

Also validates that a package with the given name or id exists.

Returns:the id of the package with the given name or id
Return type:string
Raises :ckan.lib.navl.dictization_functions.Invalid if there is no package with the given name or id
ckan.logic.converters.convert_group_name_or_id_to_id(group_name_or_id, context)

Return the group id for the given group name or id.

The point of this function is to convert group names to ids. If you have something that may be a group name or id you can pass it into this function and get the id out either way.

Also validates that a group with the given name or id exists.

Returns:the id of the group with the given name or id
Return type:string
Raises :ckan.lib.navl.dictization_functions.Invalid if there is no group with the given name or id
ckan.logic.converters.convert_to_json_if_string(value, context)