[ckan-dev] DataStore, DROP TABLE and recreate work, but DROP TABLE and recreate as VIEW fails.

Michael Nielsen mic.niel84 at gmail.com
Mon Apr 4 18:58:38 UTC 2016


Ok, after a lot of debugging I found out that in:
ckanext/datastore/logic/action.py
there's this check:

    if not data_dict['resource_id'] in WHITELISTED_RESOURCES:

        # Replace potential alias with real id to simplify access checks

        resource_id = results.fetchone()[0]

        if resource_id:

            data_dict['resource_id'] = resource_id


        p.toolkit.check_access('datastore_search', context, data_dict)

if I comment that entire check (remove it), then everything works with real
views!

Can anyone comment on this, pros and cons?

On Mon, Apr 4, 2016 at 5:10 PM, Ian Ward <ian at excess.org> wrote:

> If you need something to work immediately, you could use a trigger to
> update your table instead of using views.
>
> I encourage you to investigate the issue and submit a fix for using
> real views, though. The datastore code is quite small, and you can
> probably figure it out quickly. Even if you don't have time to extend
> the API the fix will be useful.
>
> Ian
>
> On Mon, Apr 4, 2016 at 11:03 AM, Michael Nielsen <mic.niel84 at gmail.com>
> wrote:
> > Hi Ian, as of now I'm editing directly in the DB, but it fails.
> > I'm kind of need this to work quickly. But the behaviour is very odd.
> > VIEWS does work, when my user is logged in the web and is viewable
> through
> > reclinejs, but when I'm logged OUT it does not work.
> >
> > On Mon, Apr 4, 2016 at 5:01 PM, Ian Ward <ian at excess.org> wrote:
> >>
> >> I think having postgres views as datastore resources would be great
> >> and useful in a bunch of situations.  It's not supported by the
> >> current datastore code (you've had to modify your datastore db
> >> directly). Would you be interested in adding this as a datastore
> >> feature with proper API calls and access checking?
> >>
> >> Ian
> >>
> >> On Mon, Apr 4, 2016 at 10:52 AM, Michael Nielsen <mic.niel84 at gmail.com>
> >> wrote:
> >> > 1 more thing, when using CREATE VIEW I am able to see the preview when
> >> > I'm
> >> > logged ind, but when NOT logged in, CKAN fails.
> >> >
> >> > On Mon, Apr 4, 2016 at 4:41 PM, Michael Nielsen <mic.niel84 at gmail.com
> >
> >> > wrote:
> >> >>
> >> >> I would like to have some DataStore resources as VIEWs instead of
> >> >> TABLEs.
> >> >>
> >> >> When I've created an empty DataStore resource, and deletes it with:
> >> >>
> >> >>     DROP TABLE "resource_id"
> >> >>
> >> >> everything works if I recreate the table with:
> >> >>
> >> >>     CREATE TABLE AS (SELECT * FROM view);
> >> >>
> >> >> but fails with:
> >> >>
> >> >>     CREATE VIEW AS (SELECT * FROM view);
> >> >>
> >> >> I would love CKAN to use the view, so everything is updated 100 %.
> >> >>
> >> >> Shouldn't this be possible?
> >> >>
> >> >
> >> >
> >> > _______________________________________________
> >> > ckan-dev mailing list
> >> > ckan-dev at lists.okfn.org
> >> > https://lists.okfn.org/mailman/listinfo/ckan-dev
> >> > Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
> >> >
> >> _______________________________________________
> >> ckan-dev mailing list
> >> ckan-dev at lists.okfn.org
> >> https://lists.okfn.org/mailman/listinfo/ckan-dev
> >> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
> >
> >
> >
> > _______________________________________________
> > ckan-dev mailing list
> > ckan-dev at lists.okfn.org
> > https://lists.okfn.org/mailman/listinfo/ckan-dev
> > Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
> >
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20160404/eb0e3bf4/attachment-0003.html>


More information about the ckan-dev mailing list