{ "info": { "author": "Johan Arensman", "author_email": "johan@frontendr.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Framework :: Django :: 2.1", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Python Rendertron\n\n> Rendertron middleware for Python applications.\n\n[![Build Status](https://travis-ci.org/frontendr/babel-plugin-transform-compress-graphql.svg?branch=master)](https://travis-ci.com/frontendr/python-rendertron.svg)\n[![Coverage Status](https://coveralls.io/repos/github/frontendr/python-rendertron/badge.svg?branch=develop)](https://coveralls.io/github/frontendr/python-rendertron?branch=develop)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\n[Rendertron](https://github.com/GoogleChrome/rendertron) is a headless Chrome \nrendering solution designed to render & serialise web pages on the fly. The\ngoal of this package is to provide middleware to render a request using a\nRendertron service and make the result available.\n\nThis makes it possible to for example render Progressive Web Apps (PWA), wait\nfor it to fully render (completes initial data loading etc.) and use that\nfully built markup as a response.\n\nBesides the fact that your user will see a fully rendered application faster it\nalso allows search engines to properly index the markup. \n\n## Installing\n\nInstall a Rendertron service by following the steps in\n[the documentation](https://github.com/GoogleChrome/rendertron#installing--deploying).\n\nInstall this package using `pip`:\n```bash\npip install rendertron\n```\n\nYou can also install the latest development version using `pip`'s `-e` flag:\n\n```bash\npip install -e git://git@github.com:frontendr/python-rendertron.git@develop#egg=rendertron\n```\n\nThis will install the `develop` branch.\n\n### Django\n\nFirst, add `'rendertron'` to the `INSTALLED_APPS` list in settings.\n\nThen you have 2 choices:\n - Enable the **middleware** and render everything that matches either\n `RENDERTRON_INCLUDE_PATTERNS` or does not matches anything in\n `RENDERTRON_EXCLUDE_PATTERNS`. See the Configuration section for more information about\n those.\n - Decorate specific views with the `@rendertron_render` decorator to only let render\n those views with the Rendertron service.\n\n#### Middleware\n\n1. Add `'rendertron.middleware.DjangoRendertronMiddleware'` to the `MIDDLEWARE`\nlist in the settings.\n2. Make sure to specify either `RENDERTRON_INCLUDE_PATTERNS` to specify path patterns\nwhich are to be rendered by the Rendertron service or `RENDERTRON_EXCLUDE_PATTERNS_EXTRA`\nto only specify what to exclude.\n\n#### Decorate specific views\n\nInstead of relying on the middleware and settings it is also possible to decorate\nspecific views with the `@rendertron_render` decorator.\n\n```python\nfrom rendertron.decorators.django import rendertron_render\n\n\n@rendertron_render\ndef my_view(request):\n ...\n```\n\nFor class based views use Django's [`method_decorator`](https://docs.djangoproject.com/en/dev/topics/class-based-views/intro/#decorating-the-class).\n\n```python\nfrom django.utils.decorators import method_decorator\nfrom django.views.generic import TemplateView\n\nfrom rendertron.decorators.django import rendertron_render\n\n\n@method_decorator(rendertron_render, name=\"dispatch\")\nclass MyView(TemplateView):\n ...\n```\n\n## Configuration\n\nMost configuration is done by specifying specific variables. For Django users\nthat's done in your site's settings.\n\nThe following settings are available:\n\n| Setting | Default | Description |\n|---------|---------|-------------|\n| `RENDERTRON_BASE_URL` | `'http://localhost:3000/'` | The url the Rendertron service is listening on. |\n| `RENDERTRON_RENDER_QUERY_PARAM` | `'rendertron_render'` | The query parameter added to the request url passed to Rendertron. This is used to differentiate normal requests with requests from Rendertron. |\n| `RENDERTRON_STORAGE` | See Storage | An object literal specifying and configuring the storage class to be used. See the Storage section for more information. |\n| `RENDERTRON_INCLUDE_PATTERNS` | `[]` | A list of regular expression patterns to include. Once a pattern in this list matches the request no further checking will be done. |\n| `RENDERTRON_EXCLUDE_PATTERNS` | List of common extensions. | By default this is a list of common static file type extensions used on the web. If Django is detected it's `STATIC_URL` and `MEDIA_URL` paths are added to the list. Note that if you override this setting all defaults are gone. If you want to keep these defaults *and* add your own patterns use `RENDERTRON_EXCLUDE_PATTERNS_EXTRA`.\n| `RENDERTRON_EXCLUDE_PATTERNS_EXTRA` | `[]` | Like `RENDERTRON_EXCLUDE_PATTERNS` but will be appended to that list. |\n\n## Storage\n\nStorage classes are handling the logic of storing the results coming from the\nRendertron service for a period of time. They handle if, how, where and how\nlong a result is stored. There are some core storage classes available the\nsystem is built for it to be very easy to built your own.\n\nThe choice of one of the built in storage classes depends on your framework.\n\n### Any framework: `DummyStorage`\n\nA storage class that doesn't do anything. It doesn't store and will never return\na stored result.\n\nTo use it simply set `RENDERTRON_STORAGE['CLASS']` to\n`'rendertron.storage.DummyStorage'`. It has no options.\n\n### Django: `DjangoCacheStorage`\n\nA storage class that utilizes Django's cache framework to store the results.\n\nTo use it simply set `RENDERTRON_STORAGE['CLASS']` to\n`'rendertron.storage.DjangoCacheStorage'`. It has the following options:\n\n| Setting | Default | Description |\n|---------|---------|-------------|\n| `TIMEOUT` | Django's `DEFAULT_TIMEOUT` cache setting which is `300` (5 minutes) | The number of seconds the result should be stored in the cache. It's the `timeout` argument for Django's [`cache.set`](https://docs.djangoproject.com/en/dev/topics/cache/#django.core.caches.cache.set) method. |\n| `VERSION` | `None` | The `version` argument which is passed to Django's [`cache.set`](https://docs.djangoproject.com/en/dev/topics/cache/#django.core.caches.cache.set) method. |\n\nExample config:\n\n```python\nRENDERTRON_STORAGE = {\n 'CLASS': 'rendertron.storage.DjangoCacheStorage',\n 'OPTIONS': {\n 'TIMEOUT': 300,\n }\n}\n```\n\n## Running tests\n\nFirst install Django to be able to test Django related things.\n\n```bash\npip install django\n```\n\nThen run the tests via `django-admin` using the provided minimal settings file.\n\n```bash\ndjango-admin test --pythonpath . --settings tests.django.settings\n```\n\n## License\n\nMIT\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/frontendr/python-rendertron", "keywords": "rendertron render chrome django middleware", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "rendertron", "package_url": "https://pypi.org/project/rendertron/", "platform": "", "project_url": "https://pypi.org/project/rendertron/", "project_urls": { "Homepage": "https://github.com/frontendr/python-rendertron" }, "release_url": "https://pypi.org/project/rendertron/0.2.0/", "requires_dist": null, "requires_python": ">=3", "summary": "Rendertron middleware for python applications", "version": "0.2.0" }, "last_serial": 4905500, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "73325c4e25865c3f7b4332d5269839c9", "sha256": "c3a46598b953882c4057c1c484a4dc7492bf5f1bf6cae9584907faf63b1d9187" }, "downloads": -1, "filename": "rendertron-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "73325c4e25865c3f7b4332d5269839c9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 10365, "upload_time": "2019-03-02T18:40:41", "url": "https://files.pythonhosted.org/packages/f5/b0/9bb7dc6f5438c39322d606defd422af9887828d063cf6ed84c67be85c11c/rendertron-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b09a02b97c7a5bbb0fe01f4cf81c5113", "sha256": "01cc7ee3f9c5b3320df3b81731d861be374ab2fa8c4c623cf48e5228bcef4ada" }, "downloads": -1, "filename": "rendertron-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b09a02b97c7a5bbb0fe01f4cf81c5113", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 7722, "upload_time": "2019-03-02T18:40:43", "url": "https://files.pythonhosted.org/packages/0c/d8/58cc5f45875c8d35d9406821d1da88fdce11b0d5e9ebfc4f423ab6f8d606/rendertron-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "9751c15a837c7b41cf5bb448fe3ab324", "sha256": "f77cd07b471538fb876dfb89831be043e9a749cb5510ffde556f9f87260cd82b" }, "downloads": -1, "filename": "rendertron-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9751c15a837c7b41cf5bb448fe3ab324", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 11220, "upload_time": "2019-03-03T19:56:10", "url": "https://files.pythonhosted.org/packages/3f/ff/1cf2b0643715105925f82c6f32be5b5db231c1e303dc4f059685f54b012e/rendertron-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e0ee794ace119557127c9f58dfb7271c", "sha256": "8c5004008db78d974bb8b3666a596ab6663948a0495d4b554b97c3e4e9a38dc4" }, "downloads": -1, "filename": "rendertron-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e0ee794ace119557127c9f58dfb7271c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 8135, "upload_time": "2019-03-03T19:56:11", "url": "https://files.pythonhosted.org/packages/ef/fa/5bc9190bd77b2299c5c48974e90915eca1261990a2f733bc6b25fddbb37b/rendertron-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "decaa6ac44acae81c08fa0f6843d2a56", "sha256": "e6966c1391e71fb72754390e8cf30d74ed8a74f7a7ccc43255132789743bc9db" }, "downloads": -1, "filename": "rendertron-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "decaa6ac44acae81c08fa0f6843d2a56", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 6620, "upload_time": "2019-03-06T13:41:50", "url": "https://files.pythonhosted.org/packages/c8/ed/c8e93815d9a569d1eb0cd7c872398b46d8cefad8ee67e6e99f4016ba9ea1/rendertron-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2e3a35cdc9d66ba54112fc32870664e3", "sha256": "bd9347bf2a66f1438de07cfa46ee448e193ba3fc6b70c3fbc082227786a5e348" }, "downloads": -1, "filename": "rendertron-0.2.0.tar.gz", "has_sig": false, "md5_digest": "2e3a35cdc9d66ba54112fc32870664e3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 5526, "upload_time": "2019-03-06T13:41:52", "url": "https://files.pythonhosted.org/packages/0d/16/43bb6621c056866d2f1f45120a5d244cd74d3ebd8feda967419e344746f3/rendertron-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "decaa6ac44acae81c08fa0f6843d2a56", "sha256": "e6966c1391e71fb72754390e8cf30d74ed8a74f7a7ccc43255132789743bc9db" }, "downloads": -1, "filename": "rendertron-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "decaa6ac44acae81c08fa0f6843d2a56", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 6620, "upload_time": "2019-03-06T13:41:50", "url": "https://files.pythonhosted.org/packages/c8/ed/c8e93815d9a569d1eb0cd7c872398b46d8cefad8ee67e6e99f4016ba9ea1/rendertron-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2e3a35cdc9d66ba54112fc32870664e3", "sha256": "bd9347bf2a66f1438de07cfa46ee448e193ba3fc6b70c3fbc082227786a5e348" }, "downloads": -1, "filename": "rendertron-0.2.0.tar.gz", "has_sig": false, "md5_digest": "2e3a35cdc9d66ba54112fc32870664e3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 5526, "upload_time": "2019-03-06T13:41:52", "url": "https://files.pythonhosted.org/packages/0d/16/43bb6621c056866d2f1f45120a5d244cd74d3ebd8feda967419e344746f3/rendertron-0.2.0.tar.gz" } ] }