Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

AttributeError when submitting the request form with captcha #18

Open
olivierdalang opened this issue May 13, 2020 · 3 comments
Open

AttributeError when submitting the request form with captcha #18

olivierdalang opened this issue May 13, 2020 · 3 comments

Comments

@olivierdalang
Copy link

Everything is in the title

URL: http://127.0.0.1/dataset/presentation-2012/restricted_request_access/2b4fc8e6-b0a9-424c-9d51-6e28843721af
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/weberror/evalexception.py', line 429 in respond
  app_iter = self.application(environ, detect_start_response)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py', line 147 in __call__
  resp = self.call_func(req, *args, **self.kwargs)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py', line 208 in call_func
  return self.func(req, *args, **kwargs)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/fanstatic/publisher.py', line 234 in __call__
  return request.get_response(self.app)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py', line 1053 in get_response
  application, catch_exc_info=False)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py', line 1022 in call_application
  app_iter = application(self.environ, start_response)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py', line 147 in __call__
  resp = self.call_func(req, *args, **self.kwargs)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/dec.py', line 208 in call_func
  return self.func(req, *args, **kwargs)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/fanstatic/injector.py', line 54 in __call__
  response = request.get_response(self.app)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py', line 1053 in get_response
  application, catch_exc_info=False)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py', line 1022 in call_application
  app_iter = application(self.environ, start_response)
File '/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/pylons_app.py', line 262 in inner
  result = application(environ, start_response)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/beaker/middleware.py', line 73 in __call__
  return self.app(environ, start_response)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/beaker/middleware.py', line 156 in __call__
  return self.wrap_app(environ, session_start_response)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/routes/middleware.py', line 131 in __call__
  response = self.app(environ, start_response)
File '/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/common_middleware.py', line 30 in __call__
  return self.app(environ, start_response)
File '/usr/lib/ckan/venv/src/ckan/ckan/config/middleware/common_middleware.py', line 56 in __call__
  return self.app(environ, start_response)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pylons/wsgiapp.py', line 125 in __call__
  response = self.dispatch(controller, environ, start_response)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pylons/wsgiapp.py', line 324 in dispatch
  return controller(environ, start_response)
File '/usr/lib/ckan/venv/src/ckan/ckan/lib/base.py', line 240 in __call__
  res = WSGIController.__call__(self, environ, start_response)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 221 in __call__
  response = self._dispatch_call()
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 172 in _dispatch_call
  response = self._inspect_call(func)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 107 in _inspect_call
  result = self._perform_call(func, args)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pylons/controllers/core.py', line 60 in _perform_call
  return func(**args)
File '/ckan-restricted/ckanext/restricted/controller.py', line 193 in restricted_request_access_form
  return self._send_request(context)
File '/ckan-restricted/ckanext/restricted/controller.py', line 131 in _send_request
  captcha.check_recaptcha(request)
File '/usr/lib/ckan/venv/src/ckan/ckan/lib/captcha.py', line 20 in check_recaptcha
  recaptcha_response_field = request.form.get('g-recaptcha-response', '')
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/werkzeug/local.py', line 347 in __getattr__
  return getattr(self._get_current_object(), name)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/registry.py', line 137 in __getattr__
  return getattr(self._current_obj(), attr)
File '/usr/lib/ckan/venv/local/lib/python2.7/site-packages/webob/request.py', line 1181 in __getattr__
  raise AttributeError(attr)
AttributeError: form
olivierdalang added a commit to olivierdalang/ckanext-restricted that referenced this issue May 13, 2020
@espona
Copy link
Contributor

espona commented May 14, 2020

Thanks a lot Oliver, we never experienced this issue but as log as it works for our instance I would do the workaround you proposed. May I ask you which version of CKAN are you using?

@olivierdalang
Copy link
Author

I'm using 2.8.3. I'm not sure the fix makes sense as I'm very new to pylons, maybe it hides something more serious, as from elsewhere in the code it seems request.form should work.

@MandanaMoshref
Copy link

This problem is due to changes in ckan/lib/captcha.py from version >= 2.8.3.
recaptcha_response_field = request.params.get('g-recaptcha-response', '')
is changed to: https://github.com/ckan/ckan/blob/a86242a10ef0246e0c7ddd871ba5abd344f010af/ckan/lib/captcha.py#L20

I assume the workaround should work.

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

No branches or pull requests

3 participants