[ckan-dev] Resource plugin interface

Tryggvi Björgvinsson tryggvi.bjorgvinsson at okfn.org
Wed Aug 6 20:48:22 UTC 2014


Hi all,

This is my first message to this list, but a few of you might already
know me from other places.

I've been developing a CKAN extension which will require me to monitor
resource modifications, i.e. creation, updates, and deletes for
analysis. Currently there is no single interface for plugins to do that.

So I thought I might as well just hack on CKAN and add it, since that's
what open source is about: I need something, I can add it :-)

So I looked around and found out that Sean Hammond created a branch for
the datapackager which includes a new interface, IResourceUpload which
is triggered when a file is uploaded (and also when it is deleted).

Now, Sean's addition goes a long way but it's not enough. I need this to
also be called for just normal links because I want to watch all
resource modifications. What I need help with is about what the
interface convention is. I can't really grasp it by looking at the file.

I see two possible ways:

1. More, smaller, more focussed interfaces. I notice this with for
example IResourceUrlChange. That's a pretty small and very focussed
interface.
2. Fewer, bigger, more general interfaces. I notice this with
IDomainObjectModification which in that case just takes in an operation
as a parameter.

As I understand it, Sean's IResourceUpload strikes a middle ground by
being slightly more general (an interface about uploaded files, but not
only uploads of them, also deletions). Now that I'm going to build on
Sean's work and extend it to links as well as uploads I was wondering
which direction we would like to go in.

I lean towards the latter (way 2), mixed with Sean's way (more general
interfaces with focussed methods). So something like:

class IResourceModification(Interface):
...
    def after_resource_creation(...):
    ...
    def after_resource_deletion(...):
    ...
    def after_resource_update(...):
    ...

Something like that. However that would mean (in my mind) that we should
move the IResourceUrlChange into the IResourceModification (since that's
just a special case of an update).

Does that make sense? Does anyone have any comments about this?

-- 

Tryggvi Björgvinsson

Technical Lead, OpenSpending

The Open Knowledge Foundation <http://okfn.org>

/Empowering through Open Knowledge/

http://okfn.org/ | @okfn <http://twitter.com/OKFN> | OKF on Facebook
<https://facebook.com/OKFNetwork> | Blog <http://blog.okfn.org/> |
Newsletter <http://okfn.org/about/newsletter>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140806/0a7c7747/attachment-0002.html>


More information about the ckan-dev mailing list