{ "info": { "author": "Matthew Tretter", "author_email": "m@tthewwithanm.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Topic :: Utilities" ], "description": "A Quick Tour\n============\n\ndjango-ecstatic is an expansion pack for ``django.contrib.staticfiles``!\nRead the full documentation at readthedocs__.\n\nHere are some things it can do:\n\n- Eliminate the need for network connections to calculate file hashes.\n- Collect only the static files that have changed.\n- Add content hashes to your filenames, without failing on non-existent files.\n- Create static manifests to reduce network operations and ease deployment.\n\nEcstatic's utlities are written with the same interfaces as\n``django.contrib.staticfiles``, so they should be compatible with your favorite\nDjango storage libraries.\n\n\n__ http://django-ecstatic.readthedocs.org/\n__ https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#cachedstaticfilesstorage\n__ https://www.google.com/search?q=far+future+expiration\n__ https://docs.djangoproject.com/en/dev/ref/settings/#staticfiles-storage\n\n\n\nHashed Filenames FTW\n--------------------\n\nFirst of all, you should already be using Django's CachedFilesMixin or\nCachedStaticFilesStorage__ classes, which add a post-processing step to the\n`collectstatic` command that saves a copy of your static files with a hash of\ntheir contents in the filename. If you're serving the files yourself, this will\nallow you to set `far-future expirations`__ for your assets, which will make\nyour site's users happy. It also means that new versions of assets won't\noverwrite the old versions, which would break your site if the deployed code and\nstatic files aren't in sync.\n\nHowever, in order to get the content hash, these classes will open the file\nusing your app's STATICFILES_STORAGE__. If you're using a CDN, this means\nthey'll be performing network operations. But those static files are saved on\nthe local filesystem, too\u2014after all, they were collected from somewhere. That's\nwhere ``ecstatic.storage.CachedStaticFilesMixin`` and\n``ecstatic.storage.CachedStaticFilesStorage`` come in. Instead of using the\nstorage class to get the hash, they'll use your app's staticfiles finders to\nfind the local version and use its hash. (They also have a couple of other handy\nfeatures.) Use the mixin with the storage class of your choice to get the\nbenefits:\n\n.. code-block:: python\n\n from ecstatic.storage import CachedStaticFilesMixin\n from cumulus.storage import CloudFilesStaticStorage\n\n\n class MyStaticFilesStorage(CachedStaticFilesMixin, CloudFilesStaticStorage):\n pass\n\n\nHashed Filenames and Built Files\n--------------------------------\n\nRemember when I mentioned how ``ecstatic.storage.CachedStaticFilesMixin`` and\n``ecstatic.storage.CachedStaticFilesStorage`` worked? They calculate the hashes\nof the local versions of the static files. Obviously, then, the local\nversions\u2014that is, the static files on your app server\u2014need to be the same as the\nones you collected to your CDN. Otherwise, the app server would get different\nhashes and use the wrong URL! So if your project requires a build step, you need\nto make sure that the built files are on your app server. There are two ways\nto do this:\n\n1. Include your built files in your package and deploy them with the rest of\n your application code.\n2. Re-build the static files on the app server.\n\nAlternatively, you can go back to using\n``django.contrib.staticfiles.storage.CachedFilesMixin`` or\n``django.contrib.staticfiles.storage.CachedStaticFilesStorage``, though then\nyou're back in the situation of using network operations to get the hash.\n\nAll of the above options have pros and cons. If you deploy directly from\nversion control, option 1 would mean committing compiled files to your\nrepository, which you may consider bloat. On the other hand, option 2 means that\nyour app server needs to have all of your build tools installed. It also means\nthat there will be some time while new code is deployed, but it's referencing\nold assets (until the build completes so the storage can get the new hash).\n\nLuckily, Ecstatic has another solution:\n``ecstatic.storage.StaticManifestMixin``. This mixin is used just like\n``ecstatic.storage.CachedStaticFilesMixin``, but it looks up your static files\nURLs in a manifest file\u2014completely sidestepping the need to calculate the hash\nof the local files.\n\n.. code-block:: python\n\n from ecstatic.storage import CachedStaticFilesMixin, StaticManifestMixin\n from cumulus.storage import CloudFilesStaticStorage\n\n\n class MyStaticFilesStorage(StaticManifestMixin, CachedStaticFilesMixin, CloudFilesStaticStorage):\n pass\n\n.. note::\n\n Notice that we're still including ``CachedStaticFilesMixin``. It (or\n Django's version) is still needed for the post-processing, and to figure out\n which URL should be inserted into the manifest.\n\nWith this mixin, the storage no longer needs access to the built files to\ndetermine their hashes (and therefore URLs); it only needs to access the\nmanifest file. That means:\n\n- You don't need to package your built static files with your app.\n- You don't need to install your build tools on your app server.\n- The storage class can lookup the new URL as soon as new code is deployed\n (along with a new staticfiles manifest).\n- We still aren't performing network operations to get hashes/URLs.\n\nIn other words, we've solved all of our issues. Yay!\n\nSo how do you create this manifest? First, you need to add a variable to your\nsettings.py file to let Ecstatic know where to create it:\n\n.. code-block:: python\n\n ECSTATIC_MANIFEST_FILE = os.path.join(os.path.dirname(__file__), 'staticmanifest.json')\n\nThen just run the ``createstaticmanifest`` management command:\n\n.. code-block:: sh\n\n ./manage.py createstaticmanifest\n\n.. note::\n\n When you run ``createstaticmanifest``, make sure that the Django settings\n you're using contain the correct ``STATICFILES_STORAGE``. If you have a\n local_settings.py that sets a different ``STATICFILES_STORAGE``, the\n manifest will contain the URLs that it reports!", "description_content_type": null, "docs_url": null, "download_url": "http://github.com/hzdg/django-ecstatic/tarball/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/hzdg/django-ecstatic", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-ecstatic", "package_url": "https://pypi.org/project/django-ecstatic/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-ecstatic/", "project_urls": { "Download": "http://github.com/hzdg/django-ecstatic/tarball/master", "Homepage": "http://github.com/hzdg/django-ecstatic" }, "release_url": "https://pypi.org/project/django-ecstatic/0.2.2/", "requires_dist": null, "requires_python": null, "summary": "An expansion pack for django.contrib.staticfiles!", "version": "0.2.2" }, "last_serial": 3651963, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "3d01e86d483824211eb4a7edb68ed796", "sha256": "0402377173471a725828044c7861559ca3f42cc6a1173a894dc38b3fa1b281a8" }, "downloads": -1, "filename": "django-ecstatic-0.1.tar.gz", "has_sig": false, "md5_digest": "3d01e86d483824211eb4a7edb68ed796", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14080, "upload_time": "2013-07-10T18:49:05", "url": "https://files.pythonhosted.org/packages/6c/76/9e2d3ff5f452f9674dec8711f5cfae448700a270e1e5da9cd5d30f0508f2/django-ecstatic-0.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "c91cf77f58d70a5c7783bbcf07022689", "sha256": "40cb07de66364f449467936ae243c3a562ec97c2bb372ffc89b56219265accbf" }, "downloads": -1, "filename": "django-ecstatic-0.2.0.tar.gz", "has_sig": false, "md5_digest": "c91cf77f58d70a5c7783bbcf07022689", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14146, "upload_time": "2014-01-03T19:37:46", "url": "https://files.pythonhosted.org/packages/9b/2a/63dfd62439d60b7d95c63fe74bb57f45c70ba7a4abde53a487e179aa984d/django-ecstatic-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "00520f8d2fd0ee12a7822171980ed632", "sha256": "06b567b79a2d91b0a62c9506c2aa4d1f1bb3681f317f0d74bfee7ad09e50c2d9" }, "downloads": -1, "filename": "django-ecstatic-0.2.1.tar.gz", "has_sig": false, "md5_digest": "00520f8d2fd0ee12a7822171980ed632", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14161, "upload_time": "2014-10-15T14:17:56", "url": "https://files.pythonhosted.org/packages/78/3f/6da052a41aacbaea1a8add1ea6b5a6864d6a2be94332b42f9273cfad260d/django-ecstatic-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "cd04bf89c80ae018280e90fcb107809c", "sha256": "04e8fe75a0ee56ecb39d7362886ca2a26c89eea70587cc367040487cbd88fcf4" }, "downloads": -1, "filename": "django-ecstatic-0.2.2.tar.gz", "has_sig": false, "md5_digest": "cd04bf89c80ae018280e90fcb107809c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14183, "upload_time": "2016-02-29T02:41:16", "url": "https://files.pythonhosted.org/packages/79/91/9f9d41b1bd1cdf527a60e1edb67afb5e873938f60ea9b61c35daa37cc9b8/django-ecstatic-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cd04bf89c80ae018280e90fcb107809c", "sha256": "04e8fe75a0ee56ecb39d7362886ca2a26c89eea70587cc367040487cbd88fcf4" }, "downloads": -1, "filename": "django-ecstatic-0.2.2.tar.gz", "has_sig": false, "md5_digest": "cd04bf89c80ae018280e90fcb107809c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14183, "upload_time": "2016-02-29T02:41:16", "url": "https://files.pythonhosted.org/packages/79/91/9f9d41b1bd1cdf527a60e1edb67afb5e873938f60ea9b61c35daa37cc9b8/django-ecstatic-0.2.2.tar.gz" } ] }