[ckan-dev] Schema "tree-like" update
Ian Ward
ian at excess.org
Thu Dec 18 15:37:31 UTC 2014
On Thu, Dec 18, 2014 at 8:51 AM, Funquist Tomas <tomas.funquist at smhi.se> wrote:
> Hello!
Hello Tomas,
Yes it is possible, but you have to handle making your tree-like
objects flat for storing in the DB and you need to accept a flat
representation if you want to be able to update them from the dataset
editing form.
>
> Is it in a plugin possible to update the schema to have “tree-like”
> structure like eg:
[...]
>
> “accessconstraint": [
>
> "Pending Patent",
>
> "Trademark"
>
> ],
ckanext-repeating[1] has validators[2] you can use for lists of strings.
[1]: https://github.com/open-data/ckanext-repeating
[2]: https://github.com/open-data/ckanext-repeating/blob/master/ckanext/repeating/validators.py
[...]
>
> "geographics": {
>
> "north": “90”,
>
> "south": “90”,
>
> "west": “90”,
>
> "east": “90”
>
> },
ckanext-fluent[3] uses dicts for different language versions, so you
could write something similar to its validators[4] for your schema.
[3]: https://github.com/open-data/ckanext-fluent/
[4]: https://github.com/open-data/ckanext-fluent/blob/master/ckanext/fluent/validators.py
[...]
> "contact": {
>
> "name": “Arne Weise”,
>
> "orgname": “SVT”,
>
> "role": "author",
>
> "email": [
>
> “a at b.se",
>
> "c at d.se"
>
> ]
Again, you would need a pair of custom validators for more interesting
nested objects like this, but it can be done.
There is also someone working on a more advanced way of specifying
metadata schemas based on zope schemas. When that's released as a
separate extension that might be a really good fit for what you want.
Ian
More information about the ckan-dev
mailing list