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

Joshua Tauberer tauberer+consulting at govtrack.us
Sun Jun 30 20:53:31 BST 2013


Hey, Toby.

Just belatedly following up on this thread (inline below):

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.

Not all of that has landed in a release. It looks like BaseController 
didn't make it:

https://github.com/okfn/ckan/blob/release-v2.0.1/ckan/plugins/toolkit.py


> 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.

Got it.

I ended up using IConfigurer. I wanted a config option to be able to 
control the path of a route, and only IConfigurer's methods are called 
before before_map/after_map.

> 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, {})

Got it. Much easier.

Thanks again for looking it over and providing feedback. Really appreciated.

Josh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-discuss/attachments/20130630/0d3386ae/attachment.htm>


More information about the ckan-discuss mailing list