{ "info": { "author": "Gavin Wahl", "author_email": "gavinwahl@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "django-optimistic-lock\n======================\n\n.. image:: https://secure.travis-ci.org/gavinwahl/django-optimistic-lock.png?branch=master\n :target: https://travis-ci.org/gavinwahl/django-optimistic-lock\n\nImplements an offline optimistic lock [1]_ for Django models.\n\n\nUsage\n-----\n\nAdd a ``VersionField`` and inherit from ``VersionedMixin``.\n\n.. code-block:: python\n\n from ool import VersionField, VersionedMixin\n\n class MyModel(VersionedMixin, models.Model):\n version = VersionField()\n\n\nWhenever ``MyModel`` is saved, the version will be checked to ensure\nthe instance has not changed since it was last fetched. If there is a\nconflict, a ``ConcurrentUpdate`` exception will be raised.\n\nImplementation\n--------------\nA ``VersionField`` is just an integer that increments itself every\ntime its model is saved. ``VersionedMixin`` overrides ``_do_update``\n(which is called by ``save`` to actually do the update) to add an extra\ncondition to the update query -- that the version in the database is\nthe same as the model's version. If they match, there have been no\nconcurrent modifications. If they don't match, the UPDATE statement will\nnot update any rows, and we know that someone else saved first.\n\nThis produces SQL that looks something like::\n\n UPDATE mymodel SET version = version + 1, ... WHERE id = %s AND version = %s\n\nWhen no rows were updated, we know someone else won and we need to raise\na ``ConcurrentUpdate``.\n\n\nComparison to ``django-concurrency``\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n`django-concurrency `_ before\nversion 0.7 used ``SELECT FOR UPDATE`` to implement the version checking. I\nwanted to avoid database-level locking, so ``django-optimistic-lock`` adds a\nversion filter to the update statement, as described by Martin Fowler [1]_.\n\nAdditionally, ool takes a more minimalistic approach than\ndjango-concurrency by only doing one thing -- optimistic locking --\nwithout any monkey-patching, middleware, settings variables, admin\nclasses, or form fields. django-concurrency would probably make more sense\nif you're looking for something that will attempt to accommodate every\nsituation out of the box. Use ool if you just want a straightforward model\nimplementation and need to handle the UI and surrounding architecture\nyourself.\n\nRunning the tests\n-----------------\n::\n\n make test\n\n\n.. [1] http://martinfowler.com/eaaCatalog/optimisticOfflineLock.html\n.. [2] https://code.djangoproject.com/ticket/16649", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gavinwahl/django-optimistic-lock", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "django-optimistic-lock", "package_url": "https://pypi.org/project/django-optimistic-lock/", "platform": "", "project_url": "https://pypi.org/project/django-optimistic-lock/", "project_urls": { "Homepage": "https://github.com/gavinwahl/django-optimistic-lock" }, "release_url": "https://pypi.org/project/django-optimistic-lock/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "Offline optimistic locking for Django", "version": "1.0.0" }, "last_serial": 4654060, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "00eb2e14d5c4d732f84d1dfd0aa251b4", "sha256": "85a055aaf7051d082a08f95c154c2f4b7f43462ca3a6a44a24bbd9e439fffe67" }, "downloads": -1, "filename": "django-optimistic-lock-0.1.tar.gz", "has_sig": false, "md5_digest": "00eb2e14d5c4d732f84d1dfd0aa251b4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8075, "upload_time": "2016-12-01T23:10:05", "url": "https://files.pythonhosted.org/packages/9c/69/2a1f50786b52202ba5e3035596d9c2f5a02bd60c13bf9c119ad1fcb146ed/django-optimistic-lock-0.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "1a955192c6f15e43d0c3b9f80a12ec26", "sha256": "dcc9cdc2219e6ec36757457d1ee9e55b2ec851d75308ad1080c1c2f00951cac8" }, "downloads": -1, "filename": "django-optimistic-lock-1.0.0.tar.gz", "has_sig": false, "md5_digest": "1a955192c6f15e43d0c3b9f80a12ec26", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8046, "upload_time": "2019-01-02T20:50:15", "url": "https://files.pythonhosted.org/packages/85/72/0131f985549f9ef656dee4888dc193f37c12b2a461d04e3b6afd34c377f8/django-optimistic-lock-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1a955192c6f15e43d0c3b9f80a12ec26", "sha256": "dcc9cdc2219e6ec36757457d1ee9e55b2ec851d75308ad1080c1c2f00951cac8" }, "downloads": -1, "filename": "django-optimistic-lock-1.0.0.tar.gz", "has_sig": false, "md5_digest": "1a955192c6f15e43d0c3b9f80a12ec26", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8046, "upload_time": "2019-01-02T20:50:15", "url": "https://files.pythonhosted.org/packages/85/72/0131f985549f9ef656dee4888dc193f37c12b2a461d04e3b6afd34c377f8/django-optimistic-lock-1.0.0.tar.gz" } ] }