[ckan-dev] getting exisiting package_extra data into schema?

Koebrick, Andrew (MNIT) andrew.koebrick at state.mn.us
Tue Jun 9 16:20:00 UTC 2015


Howdy,

I am attempting to implement custom fields ala the tutorial: http://docs.ckan.org/en/latest/extensions/adding-custom-fields.html

So far, new fields work just like the tutorial suggests: data entered into the new form input elements get displayed on the new templates.  And I can see the data in the package_extra table.

However, what I am really hoping to do is have these new custom fields replace pre-existing arbitrary key/value pairs which had been entered in via the API, and which populated the "Additional Information" section of the web interface.  But after I add a new field to the appropriate functions (see code below), the pre-existing data found in package_extra table is not automatically appearing when the package is displayed.  I can edit the record, and reenter the data, and it all works out, and looks identical in the package_extra table.  But how can I have the existing key-value pairs get pulled in?

Thanks for any suggestions.  Please let me know if I am not explaining adequately.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #Shared utility functions
    def create_package_schema(self):
        schema = super(geodatamn, self).create_package_schema()
        schema = self._modify_package_schema(schema)
        return schema

    def update_package_schema(self):
        schema = super(geodatamn, self).update_package_schema()
        schema = self._modify_package_schema(schema)
        return schema

    def is_fallback(self):
        return True

    def package_types(self):
        return []

    # Actual fields
    def _modify_package_schema(self, schema):
        schema.update({
            'dsPurpose': [toolkit.get_converter('convert_to_extras'),
                                     toolkit.get_validator('ignore_missing')]
        })
        return schema

    def show_package_schema(self):
        schema = super(geodatamn, self).show_package_schema()
        schema.update({
            'dsPurpose': [toolkit.get_converter('convert_from_extras'),
                            toolkit.get_validator('ignore_missing')]
        })
        return schema
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Andrew Koebrick  |  MINNESOTA GEOSPATIAL INFORMATION OFFICE
Web Coordinator / Systems administrator / Librarian
MN.IT Services @ MNGEO
651-201-2465 (w)  |   651-296-6398 (f) |  andrew.koebrick at state.mn.us<mailto:andrew.koebrick at state.mn.us>
658 Cedar St., Room 300, St. Paul, MN 55155, www.mngeo.state.mn.us<http://www.mngeo.state.mn.us/>

[cid:image002.jpg at 01CE61F8.52552AE0]<http://www.mn.gov/oet>

Information Technology for Minnesota Government   |   mn.gov/mnit<http://www.mn.gov/oet>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150609/d7a9faca/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 1624 bytes
Desc: image001.jpg
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150609/d7a9faca/attachment-0002.jpg>


More information about the ckan-dev mailing list