[ckan-dev] customizing ckan.lib.dictization.model_save.package_dict_save()

Haq, Salman Salman.Haq at neustar.biz
Wed Jun 27 19:41:31 UTC 2012


Hi,

My extension introduces new objects in the 'pkg_dict' obtained by parsing the POST params. I want to save these objects in a database table for which I have defined the ORM model similar to the 'resource' table.

The 'pkg_dict' is saved by the function model_save.package_dict_save(). There is no easy way to customize this function. Ideally, I just want to call a new function inside it similar to package_resource_list_save().

Possible options I am debating:

 1.  Introduce a new interface for plugins that wish to implement this kind of behavior. model_save.package_dict_save() will invoke the entry point before returning and pass pkg_dict, pkg, and context arguments.
 2.  Rely on the existing IPackageController interface, but change the signature of IPackageController.edit so that it accepts the pkg_dict and context arguments also and have my plugin implement that interface to perform my validation and save logic.
 3.  Make my plugin implement IActions.package_update which is exactly the same as the ckan.logic.action.update.package_update except it calls my custom implementation of package_dict_save().

Lastly, I could monkey package model_save.package_dict_save and startup but this is an option of last resort.

Look forward to the questions and comments.

Thanks,
Salman

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120627/73e1d493/attachment-0001.html>


More information about the ckan-dev mailing list