[ckan-dev] package_dictize() vs pkg.as_dict()

Toby Dacre toby.okfn at gmail.com
Wed Apr 25 15:44:37 UTC 2012


Hi,

I notice that we have two methods for converting a package to a dict.

model.Package has a as_dict() method that returns a dict

package_dictize(pkg) also converts a package to a dict

The main differences seem to be that as_dict() just returns limited (name
only for groups/tags) groups/tags/extras where as package_dictize returns
the fuller data. I think the resources are the same but that needs
confirming.

renamed fields
--------------------
licence -> license_title

in pkg.as_dict only
-------------------------
'ckan_url'
'notes_rendered'
'ratings_average'
'ratings_count'
'relationships':

in package_dictize only
-------------------------
'relationships_as_object'
'relationships_as_subject'
 'revision_timestamp'

Also as_dict returns keys as strings model_dictize uses unicode keys

I'm not a fan of code duplication so it'd be nice if we could merge these
together maybe by adding some extra keywords/context options if needed.

What do people think about this?

Toby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120425/b5f0e1ea/attachment.html>


More information about the ckan-dev mailing list