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

Add a command to run hooks without full import #147

Open
fabienheureux opened this issue Jan 22, 2022 · 1 comment
Open

Add a command to run hooks without full import #147

fabienheureux opened this issue Jan 22, 2022 · 1 comment
Labels
enhancement New feature or request Should we or not?

Comments

@fabienheureux
Copy link
Contributor

fabienheureux commented Jan 22, 2022

While developping some import hooks, it could be useful to have a management command allowing to run hooks without running a full import again.

In my case, import attempts take several minutes because of lots of not found images that raise ConnectionError exceptions. This could be better handled, however, having a way of running only hooks without a full import could really make developping hooks faster.

I started working on this, and would be happy to submit a PR, however I would like to hear some feedback about whether it could be a bad idea before going too far.

What I have in mind is the following: split WordpressImporter.run method into several methods

  • prepare_run
  • run_hooks

prepare_run

Everything needed to run both hooks and the main import run
https://github.com/torchbox/wagtail-wordpress-import/blob/main/wagtail_wordpress_import/importers/wordpress.py#L61-L72

run_hooks

This code block could live in a single method and be called at the bottom of WordpressImporter.run method
https://github.com/torchbox/wagtail-wordpress-import/blob/main/wagtail_wordpress_import/importers/wordpress.py#L198-L222

Thoughts

It might require a "dry run" in order to set the imported_pages variables.
Also, another way of doing things could be through a command line argument --hooks_only.

@nickmoreton nickmoreton added the enhancement New feature or request label Jan 22, 2022
@nickmoreton
Copy link
Collaborator

Developing import_hooks can be a challenge especially if you are doing it on a live import. I noticed on some of your PR's/Issues you use a cut down version of the xml file which is a great idea and something I do too.

I light of that I built this: https://github.com/nickmoreton/wwi-docker-develop so I can run up a complete developing setup that includes both WordPress and Wagtail and you just run ./setup.sh after cloning it and in a couple of minutes you have Wagtail with a small import completed.

I'd love to hear what you think about it! Potentially you could create your own commands in the Wagtail part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Should we or not?
Projects
None yet
Development

No branches or pull requests

2 participants