[ckan-dev] A new ckan client library: ckanapi
Toby Dacre
toby.okfn at gmail.com
Mon Apr 15 17:38:38 UTC 2013
On 15 April 2013 17:18, Ian Ward <ian at excess.org> wrote:
> On Mon, Apr 15, 2013 at 10:59 AM, Toby Dacre <toby.okfn at gmail.com> wrote:
> > Ian,
> >
> > I'm a little concerned with these imports
> >
> > from ckan.logic import (ParameterError, NotAuthorized, NotFound,
> >
> > ValidationError)
> > from ckan.lib.search import SearchQueryError, SearchError
> >
> >
> > I'd be happier for you just to create your own exceptions like you do
> > anyhow. This will allow us to refactor ckan without breaking your code.
>
> Hi Toby, thanks for taking a look.
>
> The reason I import CKAN's exceptions is because I have code that
> calls actions on a local CKAN instance from a plugin and code that
> calls actions on a remote CKAN instance in the same place, and I would
> like the exceptions that either raise to be the same.
>
>
> https://github.com/open-data/ckanext-canada/blob/master/ckanext/canada/commands.py#L309
>
>
Looking at this, I'm not sure which version of ckan you are running but
master (will be 2.1) has some extra stuff in the plugins.toolkit that will
help avoid importing ckan stuff directly -
get_converter, get_validator, CkanCommand, DefaultDatasetForm, c
It might be worth converting to use them at some point to prevent
refactoring issues. Also we might find that we need to have nice ways to
do stuff like adding globals.
> Are you suggesting I convert the exceptions that CKAN raises to my own
> copies of them in the "local CKAN" case? .. doing something like
> checking the name of the exception?
>
This might be the best way forward
>
> You're right, if one of the exception classes gets moved then ckanapi
> will stop working in a strange way (exceptions from LocalCKAN won't
> get caught anymore) which should be fixed somehow.
>
ParameterError - I think I have seen a pull request that removes this so it
may go soon - I think it is just a redefined ValidationError
NotAuthorized, NotFound (ObjectNotFound), ValidationError can be got from
the plugins toolkit which will be stable
https://github.com/okfn/ckan/blob/master/ckan/plugins/toolkit.py
the search ones I'm not sure about, I may have a think.
Toby
>
> Ian
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20130415/382beaa0/attachment-0001.html>
More information about the ckan-dev
mailing list