Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixes #5137, #4751 This was originally reported in the issues above. On 2.9, enabling the DataPusher causes an exception at the end of the dataset creation process, when submitting the resources. The stack trace looks like this: ``` File "/home/adria/dev/pyenvs/ckan/lib/python2.7/site-packages/flask/views.py", line 163, in dispatch_request return meth(*args, **kwargs) File "/home/adria/dev/pyenvs/ckan/src/ckan/ckan/views/resource.py", line 242, in post get_action(u'resource_create')(context, data) File "/home/adria/dev/pyenvs/ckan/src/ckan/ckan/logic/__init__.py", line 472, in wrapped result = _action(context, data_dict, **kw) File "/home/adria/dev/pyenvs/ckan/src/ckan/ckan/logic/action/create.py", line 330, in resource_create model.repo.commit() File "/home/adria/dev/pyenvs/ckan/lib/python2.7/site-packages/sqlalchemy/orm/scoping.py", line 162, in do return getattr(self.registry(), name)(*args, **kwargs) File "/home/adria/dev/pyenvs/ckan/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1027, in commit self.transaction.commit() File "/home/adria/dev/pyenvs/ckan/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 494, in commit self._prepare_impl() File "/home/adria/dev/pyenvs/ckan/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 464, in _prepare_impl stx = self.session.transaction AttributeError: 'NoneType' object has no attribute 'transaction' ``` As with all SQLAlchemy session issues and DataPusher ones this one took a while to track, but essentially it boiled down to what @davidread explained [here](https://stackoverflow.com/a/56094135/235993) The `datapusher` plugin used the `notify` hook to listen to resource changes. This was fired from `resource_create` which had started a transaction. The plugin then called `datapusher_submit` which in turns calls `task_status_update`, which commits and clears the Session causing troubles later on. How this had been working up until 2.8 I don't know and I'm not keen on finding out to be honest. This PR refactors the `datapusher` plugin to use the `IResourceController.after_create` and `IResourceUrlChange.notify` hooks, which are called after commit. It adds two tests that failed before the patch as well.
- Loading branch information
Showing
2 changed files
with
142 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters