[ckan-dev] Enforcing a custom schema.

Adrià Mercader adria.mercader at okfn.org
Thu Dec 20 13:03:54 UTC 2012


Hi all,

Sorry for the late reply, we are all a bit busy before Christmas!

You are both right, custom schemas and forms are created via the
IDatasetForm interface [1].
The example that Sean pointed to [2] is a good simple start. For a
more complex example, you can have a look at the 2.0-dataset-sources
from ckanext-harvest [3], which implements a whole new dataset type,
including custom forms, validation and pages. Be aware though that
this targets master CKAN (which will at some point become 2.0) and is
under current development, so things are bound to change and maybe
broke. Also it depends on some fixes and enhancements on CKAN core,
which still need reviewing and merging [4]. In any case, it may be
worth having a look at the code.

Hope this helps,

Adrià


[1] https://github.com/okfn/ckan/blob/master/ckan/plugins/interfaces.py#L492
[2] https://github.com/okfn/ckan/tree/2750-add-docs-and-examples-for-idatasetform-and-igroupform/ckanext/example_idatasetform
[3] https://github.com/okfn/ckanext-harvest/tree/2.0-dataset-sources
[4] https://github.com/okfn/ckan/pull/233

On 19 December 2012 13:17, Peder Jakobsen | gmail <pjakobsen at gmail.com> wrote:
> Hi Knud,
>
> This is a very helpful tip, I'll look into that.  I think there is
> also some good stuff hiding inside ckanext-odg, I'll be looking at
> that today.  I'd be happy to share any information I find. Are you on
> IRC by any chance  (#ckan)
>
> Thanks,
>
> Peder Jakobsen
> Open Data Canada
>
> On Wed, Dec 19, 2012 at 6:45 AM, Knud Hinnerk Möller
> <knud at datalysator.com> wrote:
>> Hi Peder,
>>
>> I believe the form_to_db_schema, db_to_form_schema, etc. methods in DefaultDatasetForm are where you can validate extra fields. Sean pointed me to some useful example code a while ago:
>>
>> https://github.com/okfn/ckan/tree/2750-add-docs-and-examples-for-idatasetform-and-igroupform/ckanext/example_idatasetform
>>
>> I haven't gone as far as writing my own validators yet, so if you manage to come up with some working examples, would you mind posting them somewhere? I'll do the same, if I get around to it!
>>
>> Cheers,
>> Knud
>>
>> On 16.12.2012, at 03:09, Peder Jakobsen <pjakobsen at gmail.com> wrote:
>>
>>> Hi, I'm looking for any suggestions on how to enforce a custom metadata schema in both the UI and API.  There would be about about 10 extra fields that have to be validated for each document.
>>>
>>> Also, are there any documents kicking around that depicts the core model in CKAN?  (UML etc.)
>>>
>>> Thanks,
>>>
>>> Peder Jakobsen
>>>
>>>
>>>
>>> _______________________________________________
>>> ckan-dev mailing list
>>> ckan-dev at lists.okfn.org
>>> http://lists.okfn.org/mailman/listinfo/ckan-dev
>>> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>>
>>
>> _______________________________________________
>> ckan-dev mailing list
>> ckan-dev at lists.okfn.org
>> http://lists.okfn.org/mailman/listinfo/ckan-dev
>> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev




More information about the ckan-dev mailing list