Skip to content

Commit

Permalink
Merge branch 'master' into tags-and-child-models
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtoppm committed Nov 6, 2020
2 parents f438cad + 9e20909 commit 560a305
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
Expand Down
4 changes: 3 additions & 1 deletion wagtail_transfer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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)

Expand Down

0 comments on commit 560a305

Please sign in to comment.