[ckan-dev] Modify resource URL

SUPPORT OPENCITIES, Bústia Compartida support.opencities at upf.edu
Thu Jun 6 14:36:36 UTC 2013


Thanks Adrià, it's work!.

I start working in 1.8, but when the 2.0 whas published, i updated. Sorry
for the confusion.


2013/6/5 Adrià Mercader <adria.mercader at okfn.org>

> Hi,
>
> In your first email you mentioned you were using CKAN 1.8 and on your
> second 2.0.
>
> If you are using 2.0, form_to_db_schema no longer exists, you need to use
>
>     def create_package_schema(self):
>         schema = super(ExampleIDatasetFormPlugin,
> self).create_package_schema()
>         schema['url'].append(my_url_converter)
>         return schema
>
>     def update_package_schema(self):
>         schema = super(ExampleIDatasetFormPlugin,
> self).update_package_schema()
>         schema['url'].append(my_url_converter)
>         return schema
>
> def my_url_converter(value, context):
>     value = 'http://opencities.edu'
>     return value
>
> Have a look at this for more info:
>
>
> http://docs.ckan.org/en/ckan-2.0/extensions.html?highlight=idatasetform#ckan.plugins.interfaces.IDatasetForm
>
> Oh, btw, if you are talking about the resource url, not the dataset
> url, then you need to modify this field of the schema:
>
>         schema = super(ExampleIDatasetFormPlugin,
> self).create_package_schema()
>         schema['resources']['url'].append(my_url_converter)
>
>
> Hope this helps,
>
> Adrià
>
>
>
> On 5 June 2013 15:35, SUPPORT OPENCITIES, Bústia Compartida
> <support.opencities at upf.edu> wrote:
> > Hi Sean,
> >
> > Sorry for the delay of my answer. I was working in many things these
> days.
> >
> > I did try to modify the resource URL with your instructions, but it
> didn't
> > work, i couldn't change anything.
> >
> > The things i done:
> >
> > 1.First of all, I modify the example_idatasetform plugin.py and i added
> the
> > lines that you bring me. I add this in the class
> ExampleIDatasetFormPlugin:
> >
> >
> >
> --------------------------------------------------------------------------------
> > def form_to_db_schema(self):
> >         schema = super(ExampleIDatasetFormPlugin,
> self).form_to_db_schema()
> >         schema['url'].append(my_url_converter)
> >         return schema
> >
> >     def my_url_converter(value, context):
> >         value = 'http://opencities.edu'
> >         return value
> >
> >
> --------------------------------------------------------------------------------------
> >
> > 2. I put activate the plugin in the production.ini and i restart the
> > Apache2. The ckan it's work OK but when i create a dataset and i put the
> url
> > "www.google.es", when is finish the url don't change to the
> > 'http://opencities.upf.edu.
> >
> > I do something wrong?.
> >
> >
> >
> > My CKAN 2.0 is installeld in a Ubuntu 12.04 64bits.
> > Thanks you very much, and sorry now for the delay and my bad english.
> >
> >
> > 2013/5/10 Sean Hammond <sean.hammond at okfn.org>
> >>
> >> > If you need any more help getting this working, would you mind posting
> >> > your question to the ckan tag on stackoverflow.com? That way the
> >> > question can be answered publicly, and the answer might be useful to
> >> > others how find it.
> >>
> >> Ack, sorry, I got confused, didn't realise you'd posted this to the
> >> mailing list. Let us know how you can get on with the solution
> >>
> >> _______________________________________________
> >> 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
> >
> >
> >
> > _______________________________________________
> > 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
> >
>
> _______________________________________________
> 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/20130606/776f940f/attachment-0001.html>


More information about the ckan-dev mailing list