==============
A base view to tar and stream several files.
Installation
------------
pip install django-tarview
Usage and examples
------------------
To create a tar download view:
* Extend BaseTarView
* implement `get_files`
* That's it
The `get_files` method must return a list (or iterator) of file-like objects.
Example with a ContentFile:
```
from tarview.views import BaseTarView
class JustTextFilesView(BaseTarView):
"""
Generate a tar with 10 files 'fileX.txt' with a simple text,
using Djangos ContentFile
"""
def get_files(self):
for i in range(0,10):
file_like = ContentFile(b("This is file %d." % i), name="file%d.txt" % i)
yield file_like
```
Or pull them from a database like this:
```python
from tarview.views import BaseTarView
from reviews import Review
class CommentsArchiveView(BaseTarView):
"""Download at once all comments for a review."""
def get_files(self):
document_key = self.kwargs.get('document_key')
reviews = Review.objects \
.filter(document__document_key=document_key) \
.exclude(comments__isnull=True)
return [review.comments.file for review in reviews if review.comments.name]
```
View configuration
------------------
By default, the downloaded file is named `download.tar` you can set a custom name
by setting the `tarfile_name` parameter.
```python
class TarView(BaseTarView):
tarfile_name = 'something.tar'
```
Testing
-------
Django TarView uses [tox, the testing automation tool](https://tox.readthedocs.org/en/latest/),
to run tests.
To launch tests:
pip install tox
tox
Author
------
Crafted with love by luckydonald.
Modification of [Thibault Jouannic](http://www.miximum.fr)'s work.
Metadata
Release files for django-tarview 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-tarview-1.0.0.tar.gz | 4.3 kB | Without provenance | Details for django-tarview-1.0.0.tar.gz |
Release files / django-tarview-1.0.0.tar.gz
| Download URL | django-tarview-1.0.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
09248f914decdad7dfc529cff5d982ef8059ec441b1d9ce8c3443c5e05c9ea37
|
|
BLAKE2b-256 checksum How to use checksums |
5f4a4420c5598cb1f2b30529d188a3eb1875ea8a13f5b29e72fd65dc23b6d61c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-tarview 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.