{ "info": { "author": "UNKNOWN", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [], "description": "===============\r\npython-gitmodel\r\n===============\r\nA distributed, versioned data store for Python\r\n----------------------------------------------\r\n\r\npython-gitmodel is a framework for persisting objects using Git for versioning\r\nand remote syncing.\r\n\r\nWhy?\r\n----\r\nAccording to `Git's README`_, Git is a \"stupid content tracker\". That means you\r\naren't limited to storing source code in git. The goal of this project is to\r\nprovide an object-level interface to use git as a schema-less data store, as\r\nwell as tools that take advantage of git's powerful versioning capabilities.\r\n\r\npython-gitmodel allows you to model your data using python, and provides an\r\neasy-to-use interface for storing that data as git objects.\r\n\r\npython-gitmodel is based on `libgit2`_, a pure C implementation of the Git core\r\nmethods. This means that instead of calling git commands via shell, we get\r\nto use git at native speed.\r\n\r\nWhat's so great about it?\r\n-------------------------\r\n* Schema-less data store\r\n* Never lose data. History is kept forever and can be restored using git tools.\r\n* Branch and merge your production data\r\n\r\n * python-gitmodel can work with different branches\r\n * branch or tag snapshots of your data\r\n * experiment on production data using branches, for example, to test a migration\r\n\r\n* Ideal for content-driven applications\r\n\r\nExample usage\r\n-------------\r\nBelow we'll cover a use-case for a basic flat-page CMS.\r\n\r\nBasic model creation: \r\n\r\n.. code:: python\r\n\r\n from gitmodel.workspace import Workspace\r\n from gitmodel import fields\r\n \r\n ws = Workspace('path/to/my-repo/.git')\r\n\r\n class Page(ws.GitModel):\r\n slug = fields.SlugField() \r\n title = fields.CharField()\r\n content = fields.CharField()\r\n published = fields.BooleanField(default=True)\r\n\r\nThe Workspace can be thought of as your git working directory. It also acts as\r\nthe \"porcelain\" layer to pygit2's \"plumbing\". In contrast to a working\r\ndirectory, the Workspace class does not make use of the repository's INDEX and\r\nHEAD files, and instead keeps track of these in memory.\r\n\r\nSaving objects:\r\n\r\n.. code:: python\r\n\r\n page = Page(slug='example-page', title='Example Page')\r\n page.content = '

Here is an Example

Lorem Ipsum

'\r\n page.save()\r\n\r\n print(page.id)\r\n # abc99c394ab546dd9d6e3381f9c0fb4b\r\n\r\nBy default, objects get an auto-ID field which saves as a python UUID hex \r\n(don't confuse these with git hashes). You can easily customize which field in\r\nyour model acts as the ID field, for example:\r\n\r\n.. code:: python\r\n\r\n class Page(ws.GitModel):\r\n slug = fields.SlugField(id=True)\r\n \r\n # OR\r\n\r\n class Page(ws.GitModel):\r\n slug = fields.SlugField()\r\n\r\n class Meta:\r\n id_field = 'slug'\r\n \r\nObjects are not committed to the repository by default. They are, however,\r\nwritten into the object database as trees and blobs. The ``Workspace.index``\r\nobject is a ``pygit2.Tree`` that holds the uncommitted data. It's analagous to\r\nGit's index, except that the pointer is stored in memory. \r\n\r\nCreating commits is simple:\r\n\r\n.. code:: python\r\n \r\n oid = page.save(commit=True, message='Added an example page')\r\n commit = ws.repo[oid] # a pygit2.Commit object\r\n print(commit.message)\r\n\r\nYou can access previous commits using pygit2, and even view diffs between two\r\nversions of an object.\r\n\r\n.. code:: python\r\n \r\n # walking commits\r\n for commit in ws.walk():\r\n print(\"{}: {}\".format(commit.hex, commit.message)) \r\n \r\n # get a diff between two commits\r\n head_commit = ws.branch.commit\r\n prev_commit_oid = head_commit.parents[0]\r\n print(prev_commit.diff(head_commit))\r\n\r\nObjects can be easily retrieved by their id:\r\n\r\n.. code:: python\r\n \r\n page = Page.get('example-page')\r\n print(page.content)\r\n\r\n \r\nCaveat Emptor\r\n-------------\r\nGit doesn't perform very well on its own. If you need your git-backed data to\r\nperform well in a production environment, you need to get it a \"wingman\". \r\nSince python-gitmodel can be used in a variety of ways, it's up to you to\r\ndecide the best way to optimize it.\r\n\r\nStatus\r\n------\r\nThis project is under heavy development, and the API will likely change\r\ndrastically before a 1.0 release. Currently only basic model creation\r\nand saving instances will work. \r\n\r\nTODO\r\n----\r\n* Caching?\r\n* Indexing?\r\n* Query API?\r\n* Full documentation\r\n\r\n-------------------------------------------------------------------------------\r\n\r\npython-gitmodel was inspired by Rick Olson's talk, \"`Git, the Stupid NoSQL \r\nDatabase`_\" and Paul Downman's `GitModel`_ for ruby.\r\n\r\n.. _Git's README: https://github.com/git/git#readme\r\n.. _libgit2: http://libgit2.github.com\r\n.. _Git, the Stupid NoSQL Database: http://git-nosql-rubyconf.heroku.com/\r\n.. _GitModel: https://github.com/pauldowman/gitmodel/", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": "", "license": "Creative Commons Attribution-Noncommercial-Share Alike license", "maintainer": "", "maintainer_email": "", "name": "praekelt-python-gitmodel", "package_url": "https://pypi.org/project/praekelt-python-gitmodel/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/praekelt-python-gitmodel/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/praekelt-python-gitmodel/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "UNKNOWN", "version": "0.1.3" }, "last_serial": 2516256, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "4ab6a83df52988a0bae64ce9bbd60a36", "sha256": "2d3fbea67a3402c0bcab9524def4e240cc3801e8f6624a7b3c9d7a6afc3fbde7" }, "downloads": -1, "filename": "praekelt-python-gitmodel-0.1.tar.gz", "has_sig": false, "md5_digest": "4ab6a83df52988a0bae64ce9bbd60a36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22318, "upload_time": "2014-08-14T09:19:04", "url": "https://files.pythonhosted.org/packages/6d/5c/7f3f3499044b9d646fb70ad724c614ee117ea5d2235d90a640dab1b61da9/praekelt-python-gitmodel-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "53d903509f7f72671b380c2b88516cf0", "sha256": "168619648f4349011a2d2e0d17ff37fa67eb0504e2bc3f240ad6f9e11fe4e3a2" }, "downloads": -1, "filename": "praekelt-python-gitmodel-0.1.1.tar.gz", "has_sig": false, "md5_digest": "53d903509f7f72671b380c2b88516cf0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22329, "upload_time": "2014-08-21T08:03:47", "url": "https://files.pythonhosted.org/packages/eb/41/33b3c560a5edf0bccd69c5e765cac1fc04ec5b999d8ec35fd5e85f0d19c5/praekelt-python-gitmodel-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "6d64544608295967fa017098cf5d88c0", "sha256": "0688825196b9b4b9b46f840308c5db5a6e85086ac8e6801378b93affc7fa899f" }, "downloads": -1, "filename": "praekelt-python-gitmodel-0.1.2.tar.gz", "has_sig": false, "md5_digest": "6d64544608295967fa017098cf5d88c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23140, "upload_time": "2014-09-10T15:22:00", "url": "https://files.pythonhosted.org/packages/d9/1f/ee5ede793308fafeedd41bba4aaa8cb4afea60bab30538e0d7e0f3fda750/praekelt-python-gitmodel-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "8867676a879bf250255c73f5a475abe7", "sha256": "be16519646cae0593dd67d8ce171d06a320d42e35265a92a443f8d4a6cd80c81" }, "downloads": -1, "filename": "praekelt-python-gitmodel-0.1.3.tar.gz", "has_sig": false, "md5_digest": "8867676a879bf250255c73f5a475abe7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23151, "upload_time": "2014-09-30T11:06:04", "url": "https://files.pythonhosted.org/packages/af/7a/5d000fa117d22c024f194302c772987263f4e43749ba3ea316fa1ae4b990/praekelt-python-gitmodel-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8867676a879bf250255c73f5a475abe7", "sha256": "be16519646cae0593dd67d8ce171d06a320d42e35265a92a443f8d4a6cd80c81" }, "downloads": -1, "filename": "praekelt-python-gitmodel-0.1.3.tar.gz", "has_sig": false, "md5_digest": "8867676a879bf250255c73f5a475abe7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23151, "upload_time": "2014-09-30T11:06:04", "url": "https://files.pythonhosted.org/packages/af/7a/5d000fa117d22c024f194302c772987263f4e43749ba3ea316fa1ae4b990/praekelt-python-gitmodel-0.1.3.tar.gz" } ] }