[ckan-dev] Customizing group schema - problems

Krzysztof Madejski krzysztof.madejski at epf.org.pl
Tue Feb 3 17:11:44 UTC 2015


Hi guys,

I'm trying to customize group schema, add an extra field. While everything
works perfect in datasets, I've encountered problems with customizing
groups.

I can save extra field to database (using convert_to_extras), but those
values are never shown in interface (in forms or elsewhere). Debugging
through CKAN for quite a time I've found that
dictization_functions.augment_data is merging extra field definiton to
dict, while convert_from_extras expects different form. See comment in the
code below?

So what's the suggested approach to deal with that? Putting "   'extras': {
'value': [], 'key': []}, " seems like gettting too much into internals.
Maybe I'm doint sth wrong.

class OrganizationForm(p.SingletonPlugin,
ckan.lib.plugins.DefaultOrganizationForm):
    p.implements(p.IGroupForm)

  def db_to_form_schema(self):
        schema = ckan.logic.schema.default_show_group_schema()

        from_extras = tk.get_converter('convert_from_extras')
        optional = tk.get_validator('ignore_missing')

        default_validators = [from_extras, optional]
        schema.update({
                       # If i don't put these 'extras' entries in schema
                       #  dictization_functions.augment_data converts
('extras', '0', 'key') -> string
                       #  to ('extras', '0', '__extras') -> dict
                       #  and from_extras is cannot match ('extras', '0',
'key') and does nothing
                       'extras': { 'value': [], 'key': []},
                       'project_leader':default_validators
                       })
        return schema


Best,
Krzysztof

-- 
Krzysztof Madejski
Koordynator Koduj Dla Polski, Fundacja ePaństwo
Code for Poland program manager, ePF Foundation
http://forum.kodujdlapolski.pl
krzysztof.madejski at epf.org.pl
+48 664 082 823
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150203/883aa1ed/attachment-0002.html>


More information about the ckan-dev mailing list