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 option to ignore objects that fail to build #69

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ A set of helpers for baking your Django Wagtail site out as flat files.
[![Build Status](https://travis-ci.org/wagtail/wagtail-bakery.svg?branch=master)](https://travis-ci.org/wagtail/wagtail-bakery)
[![Coverage Status](https://coveralls.io/repos/github/wagtail/wagtail-bakery/badge.svg?branch=master)](https://coveralls.io/github/wagtail/wagtail-bakery?branch=master)

* Issues: [https://github.com/wagtail/wagtail-bakery/issues](https://github.com/wagtail/wagtail-bakery/issues)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like Prettier got me, would you like me to revert these style changes?

* Testing: [https://travis-ci.org/wagtail/wagtail-bakery](https://travis-ci.org/wagtail/wagtail-bakery)
* Coverage: [https://coveralls.io/github/wagtail/wagtail-bakery](https://coveralls.io/github/wagtail/wagtail-bakery)
- Issues: [https://github.com/wagtail/wagtail-bakery/issues](https://github.com/wagtail/wagtail-bakery/issues)
- Testing: [https://travis-ci.org/wagtail/wagtail-bakery](https://travis-ci.org/wagtail/wagtail-bakery)
- Coverage: [https://coveralls.io/github/wagtail/wagtail-bakery](https://coveralls.io/github/wagtail/wagtail-bakery)

Wagtail-bakery is built on top of [Django bakery](https://github.com/datadesk/django-bakery). Please read their [documentation](https://django-bakery.readthedocs.io/en/latest/) for detailed configuration and how to build default Django flat files. Yes. Wagtail-bakery is not limited to build Wagtail pages specifically, mixed content is possible!

## Features

* Single management command that will build your Wagtail site out as flat files
* Support for multisite, [theming](https://github.com/wagtail/wagtail-themes) and [multilingual](http://docs.wagtail.io/en/latest/advanced_topics/i18n/index.html) setup
* Support for `i18n_patterns`
* Support for generating a static API
* Ready to use Wagtail Buildable views to build all your (un)published pages at once (no extra code required!)
- Single management command that will build your Wagtail site out as flat files
- Support for multisite, [theming](https://github.com/wagtail/wagtail-themes) and [multilingual](http://docs.wagtail.io/en/latest/advanced_topics/i18n/index.html) setup
- Support for `i18n_patterns`
- Support for generating a static API
- Ready to use Wagtail Buildable views to build all your (un)published pages at once (no extra code required!)

## Installation

Expand Down Expand Up @@ -79,6 +79,16 @@ BAKERY_VIEWS = (

The API views use Wagtail's V2 API module. To configure the data that is rendered by these views, please refer to Wagtail's [V2 API configuration guide](http://docs.wagtail.io/en/stable/advanced_topics/api/v2/configuration.html).

In case the static file for a page fails to build (for example, because the file
name would be too long for the filesystem's maximum file name length), you can
configure wagtail-bakery to ignore the page and continue to build the rest of
the static archive. The default behavior is that wagtail-bakery will throw the
error and stop the build.

```py
BAKERY_IGNORE_OBJECTS_THAT_FAILED_TO_BUILD = True
```

## Usage

Build the site out as flat files by running the `build` management command.
Expand Down Expand Up @@ -140,6 +150,7 @@ Django/Wagtail combinations as [supported](http://docs.wagtail.io/en/latest/rele
In order to keep for CI build time from growing out of control, not all Python/Django/Wagtail combinations will be tested.

Test as follow:

- All supported Django/Wagtail combinations with the latest supported Python version.
- The latest supported Django/Wagtail combination for the remaining Python versions.

Expand All @@ -157,7 +168,7 @@ For issues [please submit an issue](https://github.com/wagtail/wagtail-bakery/is
1. Update `CHANGELOG.md`.
1. On GitHub, create a pull request and squash merge it.
1. Checkout and pull the `master` branch locally.
1. (Optional) If you need to verify anything, use `make publish-test` to upload to https://test.pypi.org and enter your PyPi *test* credentials as needed.
1. (Optional) If you need to verify anything, use `make publish-test` to upload to https://test.pypi.org and enter your PyPi _test_ credentials as needed.
1. Use `make publish` and enter your PyPi credentials as needed.
1. On GitHub, create a release and a tag for the new version.

Expand Down
10 changes: 8 additions & 2 deletions src/wagtailbakery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,14 @@ def build_object(self, obj):
self.request = RequestFactory(
SERVER_NAME=site.hostname).get(self.get_url(obj))
self.set_kwargs(obj)
path = self.get_build_path(obj)
self.build_file(path, self.get_content(obj))
try:
path = self.get_build_path(obj)
self.build_file(path, self.get_content(obj))
except (OSError, AttributeError) as exc:
if getattr(settings, 'BAKERY_IGNORE_OBJECTS_THAT_FAILED_TO_BUILD', False):
logger.exception("Failed to build object %s: %s" % (obj, exc))
else:
raise exc

def build_queryset(self):
for item in self.get_queryset().all():
Expand Down