{ "info": { "author": "Rob Madole, Helder Silva, Tim Diggins", "author_email": "tim@red56.co.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Topic :: Database" ], "description": "=====================\ndjango-immutablemodel\n=====================\nEasily make all of a django model's fields immutable after saving.\nYou can customize it to make some fields mutable.\nYou can change when it can be mutable \n(e.g. whenever the field's value is nil, or only when a particular 'lock field' is false)\n\nHistory and credits\n-------------------\nVery heavily based on Rob Madole's original code at https://bitbucket.org/robmadole/django-immutablefield and \nHelder Silva's fork at https://bitbucket.org/skandal/django-immutablefield.\nRob's was 'inspired by a Google search that didn't turn up reusable solution for making\nfields immutable inside of a Django model'.\n\n*Pulled across from hg/bitbucket to git/github because less headache as they are more familar to me (Tim)*\n\n\nInstalling\n----------\n\nOne of the following:\n\nVia the ole' standby::\n\n easy_install django-immutablemodel\n\nPip::\n\n pip install django-immutablemodel\n\nTo install directly from Github::\n\n pip install git+https://github.com/red56/django-immutablemodel\n\n.. hint:: You **do not** need to add anything into Django's ``INSTALLED_APPS``\n\nWhat does it do\n---------------\n\nAllows you to declare a Django model as immutable.\n\nIt works as a drop-in replacement for Django's own ``Model``. This means you\ncan ``ImmutableModel``.\n\n::\n\n from django.db import models\n\n from immutablemodel.models import ImmutableModel\n\n CruiseShip(ImmutableModel):\n name = models.CharField(max_length=50)\n \n class Meta:\n mutable_fields = [] # you can actually leave this out...\n\t\t\t\nNow you can try with all your might, but once you've saved it won't change (within reason,\nsure this is Python we can do almost anything if we try hard enough)\n\n::\n\n >>> queen_anne = CruiseShip.objects.create(name='Queen Anne')\n \n >>> queen_anne.name = 'King George'\n >>> queen_anne.name\n 'Queen Anne'\n\nYou can make it complain\n------------------------\n\nChange the meta section to include ``immutable_quiet = False`` and it will raise a\n``ValueError`` if an attempt is made to change this value\n\n::\n\n class Meta:\n mutable_fields = [] # you can actually leave this out...\n immutable_quiet = False\n\nThe error is raised as soon as you try and set the field, not when ``save()`` is\ncalled.\n\n::\n\n >>> queen_anne = CruiseShip.objects.create(name='Queen Anne')\n \n >>> queen_anne.name = 'King George'\n ValueError: name is immutable and cannot be changed\n\nIf you want you can make ALL immutable fields complain by adding\n``IMMUTABLE_QUIET=False`` to your settings.py\n\n\nYou can make some fields mutable\n--------------------------------\n\nList the fields you actually want mutable in \"mutable_fields\"\n\n::\n\n CruiseShip(ImmutableModel):\n name = models.CharField(max_length=50)\n\t\tpassengers = models.PositiveIntegerField()\n\t\t\n class Meta:\n mutable_fields = ['passengers'] \n\n\nPlease note that fields beginning with an underscore are ignored by ImmutableModel - this allows immutable_lock_field to be a @property\n(ie. they are automatically mutable - thanks to https://github.com/Bouke for contributing a patch for this -- see https://github.com/red56/django-immutablemodel/pull/1)\n\nReference\n---------\n\n**Meta**\n\n Specify options (in addition to the normal django model's Meta options) that \n control how immutable fields are handled when\n subclassing the ``ImmutableModel`` class\n\n ``mutable_fields``\n\n Tell ``ImmutableModel`` which fields should be allowed to change.\n This value must be a tuple or a list and contain the names of the fields\n as strings.::\n\n class Meta:\n mutable_fields = ['some_transient_data']\n\n Specify multiple fields::\n\n class ImmutableMeta:\n mutable_fields = ['some_transient_data', 'name', 'foreign_key']\n\n ``immutable_fields``\n\n Tell ``ImmutableModel`` which fields should not be allowed to change.\n NB: you can't specify mutable_fields AND immutable_fields.\n This value must be a tuple or a list and contain the names of the fields\n as strings.::\n\n class Meta:\n immutable_fields = ['my_special_id']\n\n Specify multiple fields::\n\n class ImmutableMeta:\n immutable_fields = ['my_special_id', 'name', 'foreign_key']\n \n ``immutable_quiet``\n\n If an attempt is made to change an immutable field, should we quietly\n prevent it.\n\n Set this value to ``False`` to raise a ``ValueError`` when an immutable\n field is changed.::\n\n class ImmutableMeta:\n immutable_quiet = False\n\n ``immutable_lock_field``\n\n This determines when to enforce immutability. By default it is equal to immutable_model.models.PK_FIELD.\n This means that when the PK_FIELD is full (typically when saved) the model is immutable, but before it is\n saved it is mutable.\n Alternatively you can specify a field by name, or you can set it to None, which means that you can't change\n immutable fields once they are set (even before saving).\n\n class ImmutableMeta:\n immutable_lock_field = ['is_locked']\n\n\n**settings.py**\n\n ``IMMUTABLE_QUIET``\n\n Set this to ``False`` to make all immutable_fields raise an Exception when attempting\n to be changed.\n\n\n\n.. This is your project NEWS file which will contain the release notes.\n.. Example: http://www.python.org/download/releases/2.6/NEWS.txt\n.. The content of this file, along with README.rst, will appear in your\n.. project's PyPI page.\n\nRelease notes\n=============\n\n0.1\n---\n\n*Release date: 28-Apr-2010*\n\n* Initial release by Rob Madole as django-immutablefield\n\n0.2\n---\n\n* Version by Helder Silva (skandal) on bitbucket adding sign_off field. (not formally released)\n\n0.3\n---\n\n* Version by Tim Diggins (red56) calling it django-immutablemodel and making immutability after save by default\n\n0.3.1\n---\n\n* Fixing problem with abstract models\n\n0.3.2\n---\n\n* Allowing for full inheritance of immutability options within Meta \n\n0.3.3\n---\n\n* Fixing problem where immutable (non undeletable) models with default lock_field couldn't be deleted after save (because of Django deletion collector needing to change id field)\n\n0.3.4\n---\n\n* Making fields starting with _ always mutable (ignored by immutable model)", "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/red56/django-immutablemodel", "keywords": "django model fields immutable frozen", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-immutablemodel", "package_url": "https://pypi.org/project/django-immutablemodel/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-immutablemodel/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/red56/django-immutablemodel" }, "release_url": "https://pypi.org/project/django-immutablemodel/0.3.4/", "requires_dist": null, "requires_python": null, "summary": "A base class for Django to allow immutable fields on Models", "version": "0.3.4" }, "last_serial": 789856, "releases": { "0.3": [ { "comment_text": "", "digests": { "md5": "db9080a299c4d50c9aefdb0863cd7061", "sha256": "5f6ebcebd422b78c4d2aa0857a71322758146bbbc0e431800bf2236c0f530024" }, "downloads": -1, "filename": "django-immutablemodel-0.3.tar.gz", "has_sig": false, "md5_digest": "db9080a299c4d50c9aefdb0863cd7061", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6676, "upload_time": "2012-03-15T18:45:30", "url": "https://files.pythonhosted.org/packages/e6/b6/2659fc831b857a945fa2ff92ea85a87a07673196d1ab41a8b085d478b88c/django-immutablemodel-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "98d12c48a9741226a3aab2ffd4664633", "sha256": "dace01459f51e298cdc72db88a388918aec4f8d4d783d8fac8abbd2faa16affb" }, "downloads": -1, "filename": "django-immutablemodel-0.3.1.tar.gz", "has_sig": false, "md5_digest": "98d12c48a9741226a3aab2ffd4664633", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7557, "upload_time": "2012-03-19T16:21:37", "url": "https://files.pythonhosted.org/packages/4a/58/5f0c1bed6cfa9351bdd21ded4461093a1425cc91aee170a64d8effaed8f8/django-immutablemodel-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "1727e3f96fb7941e3c8a60b8cf574aac", "sha256": "54ba34bb8d09903fe4b1639fe7abe1ed7beda43c27a565caa8d3f8cc16ef2561" }, "downloads": -1, "filename": "django-immutablemodel-0.3.2.tar.gz", "has_sig": false, "md5_digest": "1727e3f96fb7941e3c8a60b8cf574aac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7916, "upload_time": "2012-03-19T23:37:20", "url": "https://files.pythonhosted.org/packages/e2/c1/edb92fb6f5c6f6bbe2060070fd93aab8db61238e37fde8f791a0a7046ff3/django-immutablemodel-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "25bac5237488c6b890c8aa1c80981cca", "sha256": "bfba8a38f68e86f22be0110d16347cbb9e0757a63c4be9d806dbbfc0d00948d3" }, "downloads": -1, "filename": "django-immutablemodel-0.3.3.tar.gz", "has_sig": false, "md5_digest": "25bac5237488c6b890c8aa1c80981cca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8323, "upload_time": "2012-03-25T10:25:23", "url": "https://files.pythonhosted.org/packages/c9/0a/676c92051035437e0b133dcd5a8a31b4e34fc9f462c747cf3cc670099bcb/django-immutablemodel-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "ad2558fa3aaa5d9517229bbefba5ebf6", "sha256": "fe281a480ce958253f0c73667ed7fa78853451401952fb4a9a976087d152af54" }, "downloads": -1, "filename": "django-immutablemodel-0.3.4.tar.gz", "has_sig": false, "md5_digest": "ad2558fa3aaa5d9517229bbefba5ebf6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8414, "upload_time": "2013-03-12T17:17:49", "url": "https://files.pythonhosted.org/packages/5d/d4/89fd565966d9fc1c8e2419a4fd1072f1361147466909d4a6fa81d03cc265/django-immutablemodel-0.3.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ad2558fa3aaa5d9517229bbefba5ebf6", "sha256": "fe281a480ce958253f0c73667ed7fa78853451401952fb4a9a976087d152af54" }, "downloads": -1, "filename": "django-immutablemodel-0.3.4.tar.gz", "has_sig": false, "md5_digest": "ad2558fa3aaa5d9517229bbefba5ebf6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8414, "upload_time": "2013-03-12T17:17:49", "url": "https://files.pythonhosted.org/packages/5d/d4/89fd565966d9fc1c8e2419a4fd1072f1361147466909d4a6fa81d03cc265/django-immutablemodel-0.3.4.tar.gz" } ] }