{ "info": { "author": "luckydonald", "author_email": "code@luckydonald.de", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "Django TarView\n==============\n\nA base view to tar and stream several files.\n\nInstallation\n------------\n\n pip install django-tarview\n\nUsage and examples\n------------------\n\nTo create a tar download view:\n\n * Extend BaseTarView\n * implement `get_files`\n * That's it\n\nThe `get_files` method must return a list (or iterator) of file-like objects.\n\nExample with a ContentFile:\n\n\n```\nfrom tarview.views import BaseTarView\n\nclass JustTextFilesView(BaseTarView):\n \"\"\"\n Generate a tar with 10 files 'fileX.txt' with a simple text,\n using Djangos ContentFile\n \"\"\"\n def get_files(self):\n for i in range(0,10):\n file_like = ContentFile(b(\"This is file %d.\" % i), name=\"file%d.txt\" % i)\n yield file_like\n```\n\nOr pull them from a database like this:\n \n```python\nfrom tarview.views import BaseTarView\n\nfrom reviews import Review\n\nclass CommentsArchiveView(BaseTarView):\n \"\"\"Download at once all comments for a review.\"\"\"\n\n def get_files(self):\n document_key = self.kwargs.get('document_key')\n reviews = Review.objects \\\n .filter(document__document_key=document_key) \\\n .exclude(comments__isnull=True)\n\n return [review.comments.file for review in reviews if review.comments.name]\n```\n\nView configuration\n------------------\n\nBy default, the downloaded file is named `download.tar` you can set a custom name\nby setting the `tarfile_name` parameter.\n\n```python\n\nclass TarView(BaseTarView):\n tarfile_name = 'something.tar'\n```\n\nTesting\n-------\n\nDjango TarView uses [tox, the testing automation tool](https://tox.readthedocs.org/en/latest/),\nto run tests.\n\nTo launch tests:\n\n pip install tox\n tox\n\n\nAuthor\n------\n\nCrafted with love by luckydonald.\nModification of [Thibault Jouannic](http://www.miximum.fr)'s work.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/luckydonald/django-tarview/", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "django-tarview", "package_url": "https://pypi.org/project/django-tarview/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-tarview/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/luckydonald/django-tarview/" }, "release_url": "https://pypi.org/project/django-tarview/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "A simple Django base view to tar and stream several files.", "version": "1.0.0" }, "last_serial": 1843819, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "497be53c738e1104b598961151795481", "sha256": "09248f914decdad7dfc529cff5d982ef8059ec441b1d9ce8c3443c5e05c9ea37" }, "downloads": -1, "filename": "django-tarview-1.0.0.tar.gz", "has_sig": false, "md5_digest": "497be53c738e1104b598961151795481", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4328, "upload_time": "2015-12-02T18:36:42", "url": "https://files.pythonhosted.org/packages/5f/4a/4420c5598cb1f2b30529d188a3eb1875ea8a13f5b29e72fd65dc23b6d61c/django-tarview-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "497be53c738e1104b598961151795481", "sha256": "09248f914decdad7dfc529cff5d982ef8059ec441b1d9ce8c3443c5e05c9ea37" }, "downloads": -1, "filename": "django-tarview-1.0.0.tar.gz", "has_sig": false, "md5_digest": "497be53c738e1104b598961151795481", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4328, "upload_time": "2015-12-02T18:36:42", "url": "https://files.pythonhosted.org/packages/5f/4a/4420c5598cb1f2b30529d188a3eb1875ea8a13f5b29e72fd65dc23b6d61c/django-tarview-1.0.0.tar.gz" } ] }