diff --git a/README.md b/README.md index 9cc5038..4dba663 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,9 @@ The following settings are additionally recognised: Note that these settings do not accept models that are defined as subclasses through [multi-table inheritance](https://docs.djangoproject.com/en/stable/topics/db/models/#multi-table-inheritance) - in particular, they cannot be used to define behaviour that only applies to specific subclasses of Page. +* `WAGTAILTRANSFER_CHOOSER_API_PROXY_TIMEOUT = 5` + + By default, each API call made to browse the page tree on the source server has a timeout limit of 5 seconds. If you find this threshold is too low, you can increase it. This may be of particular use if you are running two local runservers to test or extend Wagtail Transfer. ## Management commands diff --git a/docs/settings.md b/docs/settings.md index af66ee1..104c415 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -87,6 +87,7 @@ that object will end up with unresolved references, to be handled by the same se Note that these settings do not accept models that are defined as subclasses through multi-table inheritance - in particular, they cannot be used to define behaviour that only applies to specific subclasses of Page. + ### `WAGTAILTRANSFER_FOLLOWED_REVERSE_RELATIONS` ```python @@ -100,6 +101,16 @@ encountering that model and relation, Wagtail Transfer will follow the reverse r if `True`, will delete any models in the reverse relation on the destination site that do not exist in the source site's reverse relation. As a result, it should only be used for models that behave strictly like child models but do not use `ParentalKey` - for example, tags, where importing an image with deleted tags should delete those tag linking models on the destination site as well. + +### `WAGTAILTRANSFER_CHOOSER_API_PROXY_TIMEOUT` + +```python +WAGTAILTRANSFER_CHOOSER_API_PROXY_TIMEOUT = 5 +``` + + By default, each API call made to browse the page tree on the source server has a timeout limit of 5 seconds. If you find this threshold is too low, you can increase it. This may be of particular use if you are running two local runservers to test or extend Wagtail Transfer. + + ## Hooks ### `register_field_adapters` diff --git a/wagtail_transfer/views.py b/wagtail_transfer/views.py index db38f84..0ee85ac 100644 --- a/wagtail_transfer/views.py +++ b/wagtail_transfer/views.py @@ -183,6 +183,8 @@ class PageChooserAPIViewSet(PagesAdminAPIViewSet): def chooser_api_proxy(request, source_name, path): source_config = getattr(settings, 'WAGTAILTRANSFER_SOURCES', {}).get(source_name) + api_proxy_timeout_seconds = getattr(settings, 'WAGTAILTRANSFER_CHOOSER_API_PROXY_TIMEOUT', 5) + if source_config is None: raise Http404("Source does not exist") @@ -194,7 +196,7 @@ def chooser_api_proxy(request, source_name, path): response = requests.get(f"{base_url}{path}?{request.GET.urlencode()}", headers={ 'Accept': request.META['HTTP_ACCEPT'], - }, timeout=5) + }, timeout=api_proxy_timeout_seconds) return HttpResponse(response.content, status=response.status_code)