Best practices for writing extensions¶
Follow CKAN’s coding standards¶
See Coding standards.
Use the plugins toolkit instead of importing CKAN¶
Try to limit your extension to interacting with CKAN only through CKAN’s plugin interfaces and plugins toolkit. It’s a good idea to keep your extension code separate from CKAN as much as possible, so that internal changes in CKAN from one release to the next don’t break your extension.
Don’t edit CKAN’s database tables¶
An extension can create its own tables in the CKAN database, but it should not write to core CKAN tables directly, add columns to core tables, or use foreign keys against core tables.
Implement each plugin class in a separate Python module¶
This keeps CKAN’s plugin loading order simple, see ckan.plugins.