{ "info": { "author": "R\u00e9my Sanchez", "author_email": "remy.sanchez@activkonnect.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Framework :: Django :: 1.7", "Framework :: Django :: 1.8", "Intended Audience :: Developers", "License :: Other/Proprietary License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "Paper\n=====\n\n.. image:: https://travis-ci.org/ActivKonnect/paper.svg?branch=develop\n :target: https://travis-ci.org/ActivKonnect/paper\n\nKeep generated fields in cache for your Django models.\n\nUsage\n~~~~~\n\nYou have two options: ``@paper`` will help you to create a calculated field that is stored in\nDjango's cache, and ``@cardboard`` will create a regular field in your model and update it in\ndatabase automatically.\n\n@paper\n------\n\nJust like the ``@property`` decorator, you just need to use the ``@paper`` decorator, that will\ntransform a method of your class into a cached property.\n\n.. code-block:: python\n\n class ModelA(models.Model):\n name = models.TextField()\n\n @paper(1, [\n ('testpaper.ModelB', lambda i: ModelA.objects.filter(children=i)),\n ])\n def count(self):\n return ModelA.objects\\\n .filter(pk=self.pk)\\\n .annotate(count=Coalesce(Sum('children__count'), 0))\\\n .values_list('count', flat=True)[0]\n\n\n class ModelB(models.Model):\n parent = models.ForeignKey('ModelA', related_name='children')\n count = models.IntegerField()\n\n``@paper`` takes 2 arguments:\n\n- The method's version number, in case you want to change the format of what is returned. By\n example, imagine you're returning a complex denormalized data structure. If at some point you\n want to add some data in it, you can simply bump the version number and it will invalidate the\n caches automatically.\n- A list of model/lister couples.\n - The model is either a model class, either an 'app.Model' string\n - The lister takes a single argument which is an instance of the updated model (here a ModelB\n objet) and returns a list of affected objects to invalidate (here a queryset of ModelA objects).\n\nThe value will be cached using Django's default cache. Please note that this requires the cache to\nbe shared across all your web worker instances, otherwise invalidation won't have any the intended\neffect.\n\nInvalidation is based on Django signals, so it requires ``save()`` or ``delete()`` to be called in\norder to work correctly. Bulk/SQL operations won't be detected automatically.\n\n@cardboard\n----------\n\nUse is very similar to ``@paper``, the main differences being the absence of versioning and the fact\nthat result is going to be stored in the model itself instead of caching it.\n\n.. code-block:: python\n\n class ModelA(models.Model):\n name = models.TextField()\n\n @cardboard(models.IntegerField(default=0), [\n ('testpaper.ModelB', lambda i: ModelA.objects.filter(children=i)),\n ])\n def count(self):\n return ModelA.objects\\\n .filter(pk=self.pk)\\\n .annotate(count=Coalesce(Sum('children__count'), 0))\\\n .values_list('count', flat=True)[0]\n\n\n class ModelB(models.Model):\n parent = models.ForeignKey('ModelA', related_name='children')\n count = models.IntegerField()\n\n``@cardboard`` takes two arguments:\n\n- The field that will be used to store results. You have to give it a sensible default value,\n because no calculation will be made upon object creation. Calculation are only triggered by the\n ``dependencies`` functions.\n- A list of dependencies, just like in ``@paper``.\n\nThe same remark goes for this technique being ``save()``/``delete()`` driven: bulk or SQL operations\nwon't trigger recalculation.\n\nLicence\n~~~~~~~\n\nThis software is licenced by ActivKonnect under the terms of the WTFPL.", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ActivKonnect/paper", "keywords": null, "license": "WTFPL", "maintainer": null, "maintainer_email": null, "name": "paper", "package_url": "https://pypi.org/project/paper/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/paper/", "project_urls": { "Homepage": "https://github.com/ActivKonnect/paper" }, "release_url": "https://pypi.org/project/paper/0.2.0/", "requires_dist": null, "requires_python": null, "summary": "Keep generated fields in cache for your Django models.", "version": "0.2.0" }, "last_serial": 1720544, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "3455d335553242bdefa8a3d036ab0ee5", "sha256": "0fb3b6d972d7dbffa4fa595bfa10b79c3c0d966e16340d9f5d87c05f546c2df7" }, "downloads": -1, "filename": "paper-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3455d335553242bdefa8a3d036ab0ee5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3191, "upload_time": "2015-08-01T19:26:57", "url": "https://files.pythonhosted.org/packages/8c/9c/1127a692ebb74776026f33ac5bff343db9929f2019e4fa19c96c54315cf3/paper-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "037ed490d0699630613817c24fdec235", "sha256": "7ea5df169877ca5322cf911f0db0a5ed5edf36d923e4a877de283c57655f87d9" }, "downloads": -1, "filename": "paper-0.2.0.tar.gz", "has_sig": false, "md5_digest": "037ed490d0699630613817c24fdec235", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3879, "upload_time": "2015-09-13T09:35:38", "url": "https://files.pythonhosted.org/packages/59/ee/f1ddb006ee51d722b8fd7760f7988a75425299419f21d32b285212efe105/paper-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "037ed490d0699630613817c24fdec235", "sha256": "7ea5df169877ca5322cf911f0db0a5ed5edf36d923e4a877de283c57655f87d9" }, "downloads": -1, "filename": "paper-0.2.0.tar.gz", "has_sig": false, "md5_digest": "037ed490d0699630613817c24fdec235", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3879, "upload_time": "2015-09-13T09:35:38", "url": "https://files.pythonhosted.org/packages/59/ee/f1ddb006ee51d722b8fd7760f7988a75425299419f21d32b285212efe105/paper-0.2.0.tar.gz" } ] }