[ckan-dev] extensions decoupling: ckan.model, get_action & metadata

Toby Dacre toby.okfn at gmail.com
Tue Jun 19 13:04:44 UTC 2012


Hello,

I've been looking at the stats extension today and looking to make it as
independent from core as we can.  There are some issues that I think need
some discussion.

1) from our dev meetup we agreed that we don't really want to have
extensions getting hold of the model directly as these are liable to
change.  We did however agree that they do need access to model.Session so
my plan is to make model.Session available via
ckan.plugins.toolkit.ckan_session (ckan_session feels better that Session
as it is an object not a class but this can change if people have strong
feelings)

2) logic.action.get_action() is available via
ckan.plugins.toolkit.get_action however there is a problem that many
actions require {'model': ckan.model} as context.  To get around this my
thought is to create a function
ckan.plugins.toolkit.call_action(action_name, context, data_dict)  that
would call the action but add 'model':ckan.model to the context if not
supplied.  We could make that optional via an extra param but I think that
just adds complication and I can't see a side effect.

3) lastly the stats extension uses sa.select() to access table data for
this it needs access to either the model.meta.metadata or a function to
return the correct sa.Table I'm not too fussed which way we go with this do
people have any opinions

4) do we make BaseController available via the plugins.toolkit?

If we resolve these issue then it should be possible to make stats
independent of core which feels like a good direction to take on the
general extension cleanups.
the current progress if anyone is interested is in branch
enhancement-2572-clean-stats-plugin

The remaining decoupling issues after that relate to the tests but I was
going to look at them once these issues are resolved and I'll post about
them separately.

Toby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120619/b61e4fcc/attachment.html>


More information about the ckan-dev mailing list