[ckan-dev] Convert a dictionary to/from extras

Khalegh Mamakani khalegh at highwaythreesolutions.com
Mon Mar 3 18:38:05 UTC 2014


I have the following in my schema definition : 

def contacts_form_schema():
    schema = {
              'name' : [convert_from_extras, ignore_missing],
              'email' : [convert_from_extras, ignore_missing],
              'delete' :[convert_from_extras, ignore_missing]
              }
    return schema

def contacts_db_schema():
    schema = {
              'name' : [ignore_missing, convert_to_extras],
              'email' : [ignore_missing, convert_to_extras],
              'delete' :[ignore_missing, convert_to_extras],
              }
    return schema

def create_package_schema(self):
    schema = super(EDC_DatasetForm, self).create_package_schema()
    schema.update({
                   'contacts' : contacts_db_schema(),
                  })
    return schema
    
def show_package_schema(self):
    schema = super(EDC_DatasetForm, self).show_package_schema()
    schema.update({
                   'contacts' : contacts_form_schema(),
                   })


When creating a dataset, I get for example (‘contacts’, 0, ’name’) as the key for convert_to_extras. However, when showing the dataset, I don’t get the same key for convert_from_extras. Any idea how to get this working? There must be way of doing this because it works for resources when converting fields to/from extras.

Thanks,
Khalegh

On Mar 3, 2014, at 8:45 AM, Khalegh Mamakani <khalegh at highwaythreesolutions.com> wrote:

> Hi everybody,
> 
> I want to add a dictionary of data like contacts : {‘name’ : …., ‘email’ : …} to a dataset.
> Does anybody know how to define dataset schema so that I can convert the dictionary data to extras and when showing the dataset convert it from extras?
> 
> Thanks,
> Khalegh

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140303/2e286565/attachment-0003.html>


More information about the ckan-dev mailing list