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

Adrià Mercader adria.mercader at okfn.org
Tue Jun 9 17:33:20 UTC 2015


Hi Andrew,

Have you tried reindexing the "old" datasets (ie the ones where the extras
were created using the API)?

The data displayed on the the dataset page and the form comes from
`package_show`, which will pull the dataset dict from Solr by default. This
means that it might be picking the old indexed version that does not
contain your custom field. Editing the dataset will force a reindex, which
will make the fields appear.

Adrià

On 9 June 2015 at 17:20, Koebrick, Andrew (MNIT) <
andrew.koebrick at state.mn.us> wrote:

>  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
>
> 658 Cedar St., Room 300, St. Paul, MN 55155, www.mngeo.state.mn.us
>
> *[image: cid:image002.jpg at 01CE61F8.52552AE0]* <http://www.mn.gov/oet>
>
> Information Technology for Minnesota Government   *|*   mn.gov/mnit
> <http://www.mn.gov/oet>
>
>
>
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150609/a39cf245/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 1624 bytes
Desc: not available
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150609/a39cf245/attachment-0003.jpg>


More information about the ckan-dev mailing list