[ckan-dev] ckan restructure and api refactor.

David Raznick kindly at gmail.com
Wed Apr 13 08:51:06 UTC 2011


Hello

I have just merged a large set of changes into default concerning the
refactor I am doing.

The plan is to restructure ckan so there is a separation as follows.

https://docs.google.com/drawings/edit?id=1s_cie8AqyZhStqcsy--FGth5Go3O3XgjnlAa2DqsMVA&hl=en_GB&pli=1

The main idea behind this restructure is so that all "Interfaces" will go
through the logic layer therefore making all the code on this level
reusable.

The "Interfaces" (wui, cli, api) should be as 'dumb' as possible and not
have to know anything about the model, they can *only* do things through the
logic layer.

There is a top level directory called logic that represents this layer.  I
expect the structure of this directory to change a lot once we learn the
best way to use it.

Currently there is a directory called "action" within it and contains the
functions that the refactored api uses.  These "actions" take a single
argument 'context' and they raise a new set of generic exceptions (found in
logic.__init__) so that the individual "interfaces" can catch and respond
to.  These exceptions consist of things like "NotFound", "ValidationError"
etc.  For example the api catches a NotFound errors and raises a 404.

The restructure also contains another layer called "ditization" (see
diagram).  This layer is intended to both convert nested dict structures to
and from the database in a specific format.  This is intended to be used by
the logic layer so that it can use this format for validation.  These
functions can be found in lib.dictization.  The logic folder has a file
called schema, these schemas validate these nested dict structures using the
validation function in lib.navl.

This restructure is not nearly complete yet, not even the api has been
completely restructured to use is.  However, there is enough structure to it
that it is usable.  All current test pass using it, so there is not damage
it being in default.  It is now fairly straight forward to add new things to
the api using it.

Its still rough round the edges so please ask me if you need to add anything
new, so we can decide the best way to do it.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20110413/c7d50964/attachment.html>


More information about the ckan-dev mailing list