Opened 21 months ago

Last modified 21 months ago

#27541 new New feature

Provide hooks to override manifest file storage in ManifestFilesMixin

Reported by: Ryan Lopopolo Owned by: nobody
Component: contrib.staticfiles Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

My use case is that I would like to run collectstatic and store static assets in S3. However, I would like to store staticfiles.json locally so I can bake it into my deployment artifact.

It seems the only way to do this right now is to create a custom mixin like this one and override read_manifest and save_manifest to use a custom storage.

It seems the current behavior can be retained by using a FileSystemStorage with location = settings.STATIC_ROOT (aka self). Can we add a manifest_storage as an overridable property?

Attachments (1)

manifest_storage.patch (1.6 KB) - added by Ryan Lopopolo 21 months ago.
manifest_storage indirection

Download all attachments as: .zip

Change History (6)

comment:1 Changed 21 months ago by Ryan Lopopolo

Component: Uncategorizedcontrib.staticfiles
Type: UncategorizedNew feature

comment:2 Changed 21 months ago by Tim Graham

I'm not sure if I understand the suggestion, can you provide a patch? Will it be backwards compatible?

comment:3 Changed 21 months ago by Ryan Lopopolo

My intent is to add a layer of indirection to allow the manifest file to be saved to a separate storage backend than the static files themselves.

I've attached a patch that shows my intent. I haven't run the tests or even the code. It should be backwards compatible.

Last edited 21 months ago by Ryan Lopopolo (previous) (diff)

Changed 21 months ago by Ryan Lopopolo

Attachment: manifest_storage.patch added

manifest_storage indirection

comment:4 Changed 21 months ago by Ryan Lopopolo

The latest patch passes all tests when running

../venv/bin/python ./runtests.py staticfiles_tests.test_storage

I could not get the whole staticfiles suite to run

EDIT: I was doing something stupid. The entire suite passes on the master and stable/1.10.x branches.

Last edited 21 months ago by Ryan Lopopolo (previous) (diff)

comment:5 Changed 21 months ago by Tim Graham

Has patch: set
Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedAccepted

It might be fine, I've not done much work with that code to say if there might be a better design. Anyway, at least docs and tests are also needed.

Note: See TracTickets for help on using tickets.
Back to Top