[ckan-discuss] Extension for generating US's /data.json standard

Joshua Tauberer tauberer+consulting at govtrack.us
Mon Jun 3 22:22:23 BST 2013


Toby,

This is incredibly helpful. Thanks so much!

(We're running an a-little-before-2.0 build, but we plan to move to the 
actual 2.0 in about a month.)

-- 
- Joshua Tauberer
- http://razor.occams.info



On 06/03/2013 07:41 AM, Toby Dacre wrote:
> On 31 May 2013 21:07, Joshua Tauberer <tauberer+consulting at govtrack.us> wrote:
>> Here in the U.S. the new Open Data Memorandum requires agencies to publish
>> data catalogs in JSON with a particular schema. [1]
>>
>> For HealthData.gov, the Drupal/CKAN data catalog for the U.S. Department of
>> Health & Human Service, we created a CKAN extension to generate the
>> /data.json file. In case anyone from other U.S. agencies is on this list, I
>> wanted to share our github project for the extension:
>>
>> ckanext-datajson: https://github.com/HHS/ckanext-datajson
>>
> Hi,
>
> I had a look at your extension.
>
> some feedback this is assuming you are running CKAN 2.0 although I
> think it would also be valid for 1.8
>
> ```
> from ckan.lib.base import BaseController, render, config
> from webhelpers.html import literal
> from pylons import c, request, response
> ```
>
> BaseController, render, literal, c, request (unused) - can all be
> accessed via the plugins toolkit eg p.toolkit.render this will reduce
> the likelyhood of breakage of you extension in later versions of ckan
> due to code refactoring.
>
> config should not be imported directly from pylons use the
> IConfigurable interface to get/process the config this is the CKAN
> supported way for extensions to access the config.
>
> sadly response is not currently available in the toolkit this is
> likely to be added somepoint soon, 2.1 if I get the time.
>
> ```
> import ckan.model
> from ckan.logic.action.get import current_package_list_with_resources
> ```
>
> actions should be accessed via p.toolkit.get_action(<name>) so that
> they can be overriden by extensions etc.
>
> also if the contexted is None then model will be autopopulated by the
> get_action() returned function so you do not import ckan.model
> ```
> packages = current_package_list_with_resources( { "model": ckan.model}, {})
> ```
> packages = current_package_list_with_resources(None, {})
>
>> output: http://hub.healthdata.gov/data.json
>>
>> The mapping to the /data.json schema is specific to the way *we* store
>> metadata in CKAN, but it at least may serve as a starting point for other
>> CKAN sites. (e.g. see
>> https://github.com/HHS/ckanext-datajson/blob/master/ckanext/datajson/plugin.py)
>>
>> [1] http://project-open-data.github.io/schema/
>>
>> Hope this is useful to others,
>>
>> --
>> - Joshua Tauberer
>> - http://razor.occams.info
>>
>>
>> _______________________________________________
>> ckan-discuss mailing list
>> ckan-discuss at lists.okfn.org
>> http://lists.okfn.org/mailman/listinfo/ckan-discuss
>> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-discuss
>>
>
>




More information about the ckan-discuss mailing list