[ckan-dev] Adding additional fields to resources.

Hendrik Bunke bunke.hendrik at gmail.com
Mon Jun 8 12:19:57 UTC 2015


Oh wait, I was to quick and didn't notice that you are trying to update a
resource. In that case you don't need a converter at all.

regards 
hendrik


--On 2015-06-08 13:17, Hendrik Bunke wrote:
> --On 2015-06-08 10:32, Milo Thurston wrote:
> > This documentation discusses adding additional fields to datasets and resources:
> > 
> > http://docs.ckan.org/en/latest/extensions/adding-custom-fields.html
> > 
> > I’m interested in adding a field (a url for a thumbnail image) to resources only, and so have done this in a plugin based on that documentation:
> > 
> > 
> > def _modify_package_schema(self, schema):
> >         _convert_to_extras = toolkit.get_converter('convert_to_extras')
> >         _ignore_missing = toolkit.get_validator('ignore_missing')
> >         _url_validator = toolkit.get_validator('url_validator')
> >         schema['resources'].update({ 'image_url' : [ _ignore_missing, _url_validator, _convert_to_extras ] })
> >         return schema
> > 
> > 
> > def show_package_schema(self):
> >         schema = super(MyPlugin, self).show_package_schema()
> >         _convert_from_extras = toolkit.get_converter('convert_from_extras')
> >         _ignore_missing = toolkit.get_validator(‘ignore_missing')
> >         _url_validator = toolkit.get_validator('url_validator')
> >         schema['resources'].update({ 'image_url' : [ _ignore_missing, _url_validator, _convert_from_extras ] })
> >         return schema
> 
> 
> In show_package_schema() 'convert_from_extras' must be put as first
> list item.
> 
> regards
> hendrik
> 

-- 
Dr. Hendrik Bunke
http://gplus.to/hbunke
http://twitter.com/hbunke
http://www.hbxt.org



More information about the ckan-dev mailing list