[ckan-dev] ckan restructure and api refactor.

David Raznick kindly at gmail.com
Thu Apr 14 08:29:33 UTC 2011


Following on from this, the api refactor is pretty much complete.  There
have been a few major changes.

* The controller rest is now named api.
* The api controller has been moved into being a single class, there are no
Version1, Version2 etc.
* There is no apiv1, apiv2 folder.
* The routing has been simplified.
* Most of the logic has been moved to the logic layer.

Thanks

David


On Wed, Apr 13, 2011 at 9:51 AM, David Raznick <kindly at gmail.com> wrote:

> 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/20110414/029a95b3/attachment-0002.html>


More information about the ckan-dev mailing list