Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problems with ~/.ckanclientrc #15

Closed
timrdf opened this issue Jan 2, 2013 · 3 comments
Closed

problems with ~/.ckanclientrc #15

timrdf opened this issue Jan 2, 2013 · 3 comments

Comments

@timrdf
Copy link
Contributor

timrdf commented Jan 2, 2013

Greetings,

I'm having some trouble getting ~/.ckanclientrc to work as https://github.com/okfn/ckanclient suggests.

While the following code works fine, it does not work when I remove the api_key argument -- even if I have specified the key in ~/.ckanclientrc (shown below).

How can I get the CkanClient to use the API key given in ~/.ckanclientrc?

Thanks for much!
Tim Lebo

import ckanclient

# Instantiate the CKAN client.
ckan = ckanclient.CkanClient(base_location='http://datahub.io/api',
                            api_key='my-key') ## 403 error if this argument is removed (why isn't ~/.ckanclientrc taking over?).

# Get the details of a package.
ckan.package_entity_get('instance-hub-fiscal-years')
package_entity = ckan.last_message
package_entity['maintainer'] = 'TWC RPI'

print package_entity

ckan.package_entity_put(package_entity)
cat ~/.ckanclientrc
[index:http://datahub.io]
api_key = my-key
@rufuspollock
Copy link
Member

@timrdf hi tim. I see @tobes has replied on list correctly indicated that there is a bug in the docs in that this is not actually supported. That said all the code for this is in the https://github.com/okfn/ckanclient/blob/master/ckanclient/datastore.py file and just needs to be moved across (I think that there had been a plan to do this but which somehow got stalled halfway).

@timrdf
Copy link
Contributor Author

timrdf commented Jan 30, 2013

Thanks, @rgrp. As I said on list, I'll work around the issue as long as I can, and then re-raise it and/or fork the repo to add the older capability.

For my own reference, I discuss this issue #15 at https://github.com/timrdf/DataFAQs/wiki/DATAFAQS-environment-variables and https://github.com/timrdf/DataFAQs/wiki/CKAN, which is where I'll continue to elaborate my need for a ~/.ckanclientrc with different api keys for different ckan instances.

Regards,
Tim

@rufuspollock
Copy link
Member

Thanks. The fix here should be pretty easy (we just need to copy some of the code from datastore.py). The moment you ahve something we can review and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants