conwetlab/ckanext-privatedatasets

More than one fallback IDatasetForm has been registered

jordipiqueres opened this issue · 16 comments

I have installed CKAN on a Ubuntu 12.04 64bit system and everything was fine. I also installed correctly these extensions:

ckan.plugins = stats image_view webpage_view recline_grid_view pdf_view spatial_metadata spatial_query datastore datapusher extrafields apihelper viewhelpers navigablemap choroplethmap barchart repo_info dashboard_preview resource_proxy geojson_preview wms_preview vegaview hierarchy_display hierarchy_form harvest ckan_harvester archiver qa

Now, I wanted to add ckanext-privatedatasets but I am having the following error:

Traceback (most recent call last):
File "/usr/lib/ckan/default/bin/paster", line 9, in
load_entry_point('PasteScript==1.7.5', 'console_scripts', 'paster')()
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 104, in run
invoke(command, command_name, options, args[1:])
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 143, in invoke
exit_code = runner.run(args)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 238, in run
result = self.command()
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/serve.py", line 284, in command
relative_to=base, global_conf=vars)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/serve.py", line 321, in loadapp
*_kw)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, *_kw)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, *_context.local_conf)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/util.py", line 56, in fix_call
val = callable(_args, *_kw)
File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware.py", line 58, in make_app
load_environment(conf, app_conf)
File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 232, in load_environment
p.load_all(config)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 134, in load_all
load(_plugins)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 166, in load
plugins_update()
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 116, in plugins_update
environment.update_config()
File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 272, in update_config
routes_map = routing.make_map()
File "/usr/lib/ckan/default/src/ckan/ckan/config/routing.py", line 343, in make_map
lib_plugins.register_package_plugins(map)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/plugins.py", line 81, in register_package_plugins
raise ValueError("More than one fallback "
ValueError: More than one fallback IDatasetForm has been registered

I would be grateful if someone can give me an advice to look for a solution to this.

As stated by CKAN: "There cannot be more than one IDatasetForm plugin whose is_fallback() method returns True, if this happens CKAN will raise an exception at startup."

ckanext-privatedataset has been set to return True when this function is called. I guess that another extension you've installed is also returning True when is_fallback() is called. You have two options:

  • You can manually edit the code of ckanext_privatedatasts to return False when is_fallback() is called.
  • You can disable the extension that returns True when is_fallback() is called.

Please, let me know if you are able to fix this issue in order to close it.

Hi @aitormagan!

Thank you so much for your answer. I did what you have suggested and now it is working. Indeed, I had another extension returning True which is extend_search I think.

As far as I am not much familiar with Python, I would like to ask you what is the prupose of the function is_fallback() and why is not strongly "necessary".

I'm really very excited with Ckan and all the community that is behind. Now, I will do some test about ckanext_privatedatasts' extension. It is very useful for what I have to do.

Thank you for helping me :)

CKAN allows developers to create new types of datasets using extensions. The extension that returns True is the one that will handle package types not recognized by other extensions.

At this time, I haven't paid attention to this detail but I'm now considering either removing is_fallback function or simply returning False.

I'll keep you posted.

Adéu! :)

Thank you for your response, it is pretty clarify :)

But I would need your advise again @aitormagan . After having done the configuration I am testing the extension without any success. Maybe I am missing something in the configuration .ini or I have misunderstood some of the described steps.

I explain the case:
Now, I can see the owner of an uploaded dataset and I can add the user's list whose have permissions to access it. It seems that everything is fine here. But once I add a new dataset with the allowed users i.e.: userA, userB, it seems that there's something wrong because I can see and access to this dataset with a user which doesn't belongs to the allowed list i.e.: userC. I thought that only userA and userB could access it.

Do you have any idea if maybe I did something worng?

Gracias :)

I do not if this is the problem, but is userC the administrator of CKAN? I'm asking this because I also had this error. Please, consider that CKAN administrators can access to every dataset (even if it's private and you haven't explicitly added them).

If this is not your error, what CKAN version are you using?

We can continue in Spanish if you want :)

Bye!

I have installed CKAN version 2.3 with some other extensions - listed in the first comment.

I am going to be more specific with the explained case:

  • Admin (as a CKAN Administrator) and UserA (non CKAN Administrator) and UserB (non CKAN Administrator) have Administration permissions on the ogranization OrgA.
  • UserC (non CKAN Administrator) is a Member on the organization OrgA.
  • UserA upload a new dataset d1 with:
    • Visibility: Private
    • Searchable: True
    • Allowed Users: Admin; UserA; UserB;
    • Acquire URL: - empty -
  • UserC is a Member of the OrgA but should not visualize d1 because of the restriction created on the Allowed Users, but UserCcan access to d1.

Before the installation of the ckanext-privatedatasets' extension I had some other datasets created. I don't know if this could be a problem for the management.

So, can we speak in Spanish here? I didn't dare to post in Spanish in order to try that my question would be useful for other "potential users" :) - btw, sorry for my English.

Gracias por la ayuda :)

When you created dataset d1, did you specify an organization? If a user is in an organization, he/she can access all the datasets that belongs to that organization (even if he/she is in the list of allowed users). This is the default behaviour defined by CKAN.

You're right, English is better for potential users! :)

You are right I specified an organization when I am creating the dataset d1. But I don't understand because, on the one hand, if I don't select an organization then I can not add a new dataset with Visibility: Private and the following error appears once I try to create it:

The form contains invalid entries:
Private: Datasets with no organization can't be private.

On the other hand, if I don't select an organization and I set Visibility: Public, Allowed Users input field and Acquire URL appear as disabled fields and I can not write the allowed user list.

Is there any configuration which makes it possible to create Private datasets without specifying the organization?

Yes! This is my fault because of the change in is_fallback(). As you have changed it to return False (because I've told you to do that) the extension is not working now. I'm completly sorry, but this function must return True if you want the extension to work. I have proposed you this solution without testing it.

When the extension is properly workinkg, you can create private datasets without organizations. I've tried to look for the other extension that is implementing the IDatasetForm interface, but I haven't found it. Please, can you send me the link to the repository where this extension is hosted? I want to install it to figure out one possible solution.

I'm really sorry about the misunderstanding.

I have undone the changes that we commented about the is_fallback() function. At first I thought that the error arises because ckanext-extend_search was the other extnension which has that function but I was worng.

The error that I get is the following:

2015-04-13 17:34:42,767 WARNI [ckan.config.environment] Support for Genshi templates is deprecated and will be removed in a future release
stat: cannot stat `.git/FETCH_HEAD': No such file or directory
Traceback (most recent call last):
File "/usr/lib/ckan/default/bin/paster", line 9, in
load_entry_point('PasteScript==1.7.5', 'console_scripts', 'paster')()
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 104, in run
invoke(command, command_name, options, args[1:])
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 143, in invoke
exit_code = runner.run(args)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/command.py", line 238, in run
result = self.command()
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/serve.py", line 284, in command
relative_to=base, global_conf=vars)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/script/serve.py", line 321, in loadapp
*_kw)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, *_kw)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, *_context.local_conf)
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/deploy/util.py", line 56, in fix_call
val = callable(_args, *_kw)
File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware.py", line 58, in make_app
load_environment(conf, app_conf)
File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 232, in load_environment
p.load_all(config)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 134, in load_all
load(_plugins)
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 166, in load
plugins_update()
File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 116, in plugins_update
environment.update_config()
File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 272, in update_config
routes_map = routing.make_map()
File "/usr/lib/ckan/default/src/ckan/ckan/config/routing.py", line 343, in make_map
lib_plugins.register_package_plugins(map)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/plugins.py", line 81, in register_package_plugins
raise ValueError("More than one fallback "
ValueError: More than one fallback IDatasetForm has been registered

Do you know how I could get more information about the error to know which is the extension with the duplicated method?

I guess you have to check them one by one... Or you can try to disable them one by one...

I am sorry @aitormagan I just remembered now. I need to customize the metadata fields which are requested on the creation of the dataset and I followed the example of CKAN guide for Customizing dataset and resource metadata fields using IDatasetForm - which implements also the is_fallback()method: > http://docs.ckan.org/en/latest/extensions/adding-custom-fields.html

Is there any way to unify these methods?

I do not know... Have you tried to return False in your is_fallback() function? Maybe it'll work in this way.

Buenos días @aitormagan ,

I just have done the changes on the ckanext-extrafields as you told me. Now, It seems that ckanext-privatedataset is working! :)

I did some tests which I explain you in order to know if that's the way on how the extension works:

  • UserA (non administrator) creates a new dataset d1:
    • Organization: No organization
    • Visibility: Private
    • Allowed Users: Admin; UserB;
  • When UserB (non administrator) is logged in, UserB can see d1 in their dataset's list and it is allowed to access into dataset d1 without editing permisions. OK
  • When UserC (non administrator) is logged in, UserC can see d1 in their dataset's list but it is not allowed to access into dataset d1. If UserC tries to access into the dataset d1, this action produces an automatic log off.

Is that something on the common behaviour of the ckanext-privatedataset functionality?

Thank you!

Ops! I realised that now my ckanext-extrafields is not working correctly and the information which I put in the extra fields is not being saved. What can I do to have both extensions working?

I guess that the solution would be to merge both extensions in a new one which has the functionalities. I don't know exactly why I can not have is_fallback() method in each extension. Do you have any other idea? I am having a look to the documentation but I am not much familiarized with python and CKAN's implementation http://docs.ckan.org/en/latest/extensions/adding-custom-fields.html#dataset-types .

What you've described is the default CKAN behaviour. When you're trying to access something and you don't have rights to access it, CKAN logs you out in oder to ask you for new credentaisl with access to this resource. You can change this behaviour by developing a new extension.

I do not know a better solution for the problems with is_fallback() function. As you mentioned, I think that the best option is to merge the two extensions in a new one.