Skip to content

Commit

Permalink
[#943] Add some minimal extension best practices
Browse files Browse the repository at this point in the history
There's probably a lot more to mention here.
  • Loading branch information
Sean Hammond committed Jun 24, 2013
1 parent 3c2fda0 commit 5b7b0b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.rst
Expand Up @@ -44,6 +44,7 @@ For contributing translations to CKAN, see

i18n

.. _coding standards:

----------------
Coding Standards
Expand Down
30 changes: 21 additions & 9 deletions doc/writing-extensions.rst
Expand Up @@ -547,15 +547,27 @@ Localizing extensions
Best practices for writing extensions
-------------------------------------

.. todo:: Write up best practices for writing extensions.

* Keep your code separate from CKAN so that internal CKAN changes
don't break your code between releases.
* import style
* Don't import ckan, use toolkit
* Use the toolkit
* get_action()
* Don't edit or key to model tables
Follow CKAN's coding standards
==============================

See :ref:`coding standards`.

Use the plugins toolkit instead of importing CKAN
=================================================

Try to limit your extension to interacting with CKAN only through CKAN's
:ref:`plugin interfaces <plugin-interfaces-reference>` and
:ref:`plugins toolkit <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
write to core CKAN tables directly, add columns to core tables, or use foreign
keys against core tables.


.. _plugin-interfaces-reference:
Expand Down

0 comments on commit 5b7b0b4

Please sign in to comment.