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

Toby Dacre toby.okfn at gmail.com
Wed Apr 25 17:01:16 UTC 2012


On 25 April 2012 17:54, Sean Hammond <sean.hammond at okfn.org> wrote:

> > 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?
>
> I think that as_dict() methods are the old way and are deprecated now in
> favor of model_dictize. Maybe the as_dict methods can be deleted (and
> any code using them updated) rather than merging?
>
>
it seems to be used in some tests and in lib/dumper.py


> I think I recall using table_dictize when I wanted to get more limited
> data (e.g. not recursing into lists of resources etc.)
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120425/2d6a1467/attachment-0001.html>


More information about the ckan-dev mailing list