{ "info": { "author": "Byron Ruth", "author_email": "b@devel.io", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "Overview\n========\nDjango-Forkit is composed of a set of utility functions for _forking_,\n_resetting_, and _diffing_ model objects. Below are a list of the current\nutility functions:\n\nforkit.tools.fork\n-----------------\nCreates and returns a new object that is identical to ``reference``.\n\n- ``fields`` - A list of fields to fork. If a falsy value, the fields\nwill be inferred depending on the value of ``deep``.\n- ``exclude`` - A list of fields to not fork (not applicable if ``fields``\nis defined)\n- ``deep`` - If ``True``, traversing all related objects and creates forks\nof them as well, effectively creating a new _tree_ of objects.\n- ``commit`` - If ``True``, all forks (including related objects) will be saved\nin the order of dependency. If ``False``, all commits are stashed away until\nthe root fork is committed.\n- ``**kwargs`` - Any additional keyword arguments are passed along to all signal\nreceivers. Useful for altering runtime behavior in signal receivers.\n\n```python\nfork(reference, [fields=None], [exclude=('pk',)], [deep=False], [commit=True], [**kwargs])\n```\n\nforkit.tools.reset\n------------------\nSame parameters as above, except that an explicit ``instance`` is rquired and\nwill result in an in-place update of ``instance``. For shallow resets, only the\nlocal non-relational fields will be updated. For deep resets, _direct_\nforeign keys will be traversed and reset. _Many-to-many and reverse foreign keys\nare not attempted to be reset because the comparison between the related objects\nfor ``reference`` and the related objects for ``instance`` becomes ambiguous._\n\n```python\nreset(reference, instance, [fields=None], [exclude=('pk',)], [deep=False], [commit=True], [**kwargs])\n```\n\nforkit.tools.commit\n-------------------\nCommits any unsaved changes to a forked or reset object.\n\n```python\ncommit(reference, [**kwargs])\n```\n\nforkit.tools.diff\n-----------------\nPerforms a _diff_ between two model objects of the same type. The output is a\n``dict`` of differing values relative to ``reference``. Thus, if\n``reference.foo`` is ``bar`` and ``instance.foo`` is ``baz``, the output will\nbe ``{'foo': 'baz'}``. _Note: deep diffs only work for simple non-circular\nrelationships. Improved functionality is scheduled for a future release._\n\n```python\ndiff(reference, instance, [fields=None], [exclude=('pk',)], [deep=False], [**kwargs])\n```\n\nForkableModel\n-------------\nAlso included is a ``Model`` subclass which has implements the above functions\nas methods.\n\n```python\nfrom forkit.models import ForkableModel\n\nclass Author(ForkableModel):\n first_name = models.CharField(max_length=30)\n last_name = models.CharField(max_length=30)\n```\n\nLet's create starting object:\n\n```python\nauthor = Author(first_name='Byron', last_name='Ruth')\nauthor.save()\n```\n\nTo create copy, simply call the ``fork`` method.\n\n```python\nauthor_fork = author.fork()\n```\n\nWhen an object is forked, it immediately inherits it's data including\nrelated objects.\n\n```python\nauthor_fork.first_name # Byron\nauthor_fork.last_name # Ruth\n```\n\nLet us change something on the fork and use the ``diff`` method to compare it\nagainst the original ``author``. It returns a dictionary of the differences\nbetween itself and the passed in object.\n\n```python\nauthor_fork.first_name = 'Edward'\nauthor_fork.diff(author) # {'first_name': 'Edward'}\n```\n\nOnce satisfied with the changes, simply call ``commit``.\n\n```python\nauthor_fork.commit()\n```\n\nSignals\n=======\nFor each of the utility function above, ``pre_FOO`` and ``post_FOO`` signals\nare sent allowing for a decoupled approached for customizing behavior, especially\nwhen performing deep operations.\n\nforkit.signals.pre_fork\n-----------------------\n\n- ``sender`` - the model class of the instance\n- ``reference`` - the reference object the fork is being created from\n- ``instance`` - the forked object itself\n- ``config`` - a ``dict`` of the keyword arguments passed into ``forkit.tools.fork``\n\nforkit.signals.post_fork\n-----------------------\n\n- ``sender`` - the model class of the instance\n- ``reference`` - the reference object the fork is being created from\n- ``instance`` - the forked object itself\n\nforkit.signals.pre_reset\n-----------------------\n\n- ``sender`` - the model class of the instance\n- ``reference`` - the reference object the instance is being reset relative to\n- ``instance`` - the object being reset\n- ``config`` - a ``dict`` of the keyword arguments passed into ``forkit.tools.reset``\n\nforkit.signals.post_reset\n-----------------------\n\n- ``sender`` - the model class of the instance\n- ``reference`` - the reference object the instance is being reset relative to\n- ``instance`` - the object being reset\n\nforkit.signals.pre_commit\n-----------------------\n\n- ``sender`` - the model class of the instance\n- ``reference`` - the reference object the instance has been derived\n- ``instance`` - the object to be committed\n\nforkit.signals.post_commit\n-----------------------\n\n- ``sender`` - the model class of the instance\n- ``reference`` - the reference object the instance has been derived\n- ``instance`` - the object that has been committed\n\nforkit.signals.pre_diff\n-----------------------\n\n- ``sender`` - the model class of the instance\n- ``reference`` - the reference object the instance is being diffed against\n- ``instance`` - the object being diffed with\n- ``config`` - a ``dict`` of the keyword arguments passed into ``forkit.tools.diff``\n\nforkit.signals.post_diff\n-----------------------\n\n- ``sender`` - the model class of the instance\n- ``reference`` - the reference object the instance is being diffed against\n- ``instance`` - the object being diffed with\n- ``diff`` - the diff between the ``reference`` and ``instance``\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": "fork deepcopy model abstract diff", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-forkit", "package_url": "https://pypi.org/project/django-forkit/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-forkit/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/django-forkit/0.9.5/", "requires_dist": null, "requires_python": null, "summary": "Utility functions for forking, resetting and diffing model objects", "version": "0.9.5" }, "last_serial": 789681, "releases": { "0.9.5": [ { "comment_text": "", "digests": { "md5": "1da511d78dd4b1a47811192bbfd83aab", "sha256": "28a550a487e091f8287203e266046e028173fe7048c8c28847b9a9709ef148a1" }, "downloads": -1, "filename": "django-forkit-0.9.5.tar.gz", "has_sig": false, "md5_digest": "1da511d78dd4b1a47811192bbfd83aab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9256, "upload_time": "2013-01-31T20:57:11", "url": "https://files.pythonhosted.org/packages/79/74/4da6e5dd97e00e449a25b18d6f3f54eece51af582eaf9920d1595378f1b8/django-forkit-0.9.5.tar.gz" } ], "0.9.5b1": [ { "comment_text": "", "digests": { "md5": "493c9b2309e94bd27366513d84463595", "sha256": "3aa7559bcb038bf05eefcc3f881c1f1ed1ea477798bbdd2204077051706b4b6f" }, "downloads": -1, "filename": "django-forkit-0.9.5b1.tar.gz", "has_sig": false, "md5_digest": "493c9b2309e94bd27366513d84463595", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8369, "upload_time": "2011-10-17T02:40:41", "url": "https://files.pythonhosted.org/packages/55/ab/3de9b32bde8fd7fdf811b3f425123f9394031572931796af72a540be58f8/django-forkit-0.9.5b1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1da511d78dd4b1a47811192bbfd83aab", "sha256": "28a550a487e091f8287203e266046e028173fe7048c8c28847b9a9709ef148a1" }, "downloads": -1, "filename": "django-forkit-0.9.5.tar.gz", "has_sig": false, "md5_digest": "1da511d78dd4b1a47811192bbfd83aab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9256, "upload_time": "2013-01-31T20:57:11", "url": "https://files.pythonhosted.org/packages/79/74/4da6e5dd97e00e449a25b18d6f3f54eece51af582eaf9920d1595378f1b8/django-forkit-0.9.5.tar.gz" } ] }