{ "info": { "author": "Andrew Godwin", "author_email": "andrew@aeracode.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Internet :: WWW/HTTP" ], "description": "yamdl\n=====\n\n.. image:: https://img.shields.io/pypi/v/yamdl.svg\n :target: https://pypi.python.org/pypi/yamdl\n\n.. image:: https://img.shields.io/pypi/l/yamdl.svg\n :target: https://pypi.python.org/pypi/yamdl\n\nLets you store instances of Django models as flat files (simplified fixtures).\nFor when you want to store content in a Git repo, but still want to be able to\nuse the normal Django ORM methods and shortcut functions.\n\nIt works by loading the data into an in-memory SQLite database on startup, and\nthen serving queries from there. This means it adds a little time to your app's\nboot, and slightly more RAM usage, but with the advantage of a much easier time\ndealing with static files (rather than custom code to load them directly).\n\nIt does not persist changes to the models back into files - this is purely for\nauthoring content in a text editor and using it via Django.\n\nDue to Python limitations yamdl currently only works on **Python 3.4** and up.\n\n\nWhy not use normal fixtures?\n----------------------------\n\nThey're not only a little verbose, but they need to be loaded into a non-memory\ndatabase (slower) and you need lots of logic to work out if you should update\nor delete existing entries. They're still a better solution for anything that\nhas a lot of data or which needs JOINs, though.\n\n\nInstallation\n------------\n\nFirst, install the package::\n\n pip install yamdl\n\nThen, add it to ``INSTALLED_APPS``::\n\n INSTALLED_APPS = [\n ...\n 'yamdl',\n ...\n ]\n\nThen, add the in-memory database to ``DATABASES`` (note that you must have at\nleast **Python 3.4** to have a SQlite module that understands shared memory URIs)::\n\n DATABASES = {\n ...\n 'yamdl': {\n 'ENGINE': 'django.db.backends.sqlite3',\n 'NAME': 'file:yamdl-db?mode=memory&cache=shared',\n }\n }\n\nThen, add a ``YAMDL_DIRECTORIES`` setting which defines where your directories\nof YAML files can be found (it's a list)::\n\n YAMDL_DIRECTORIES = [\n os.path.join(PROJECT_DIR, \"content\"),\n ]\n\nFinally, add the database router::\n\n DATABASE_ROUTERS = [\n \"yamdl.router.YamdlRouter\",\n ]\n\n\nUsage\n-----\n\nFirst, add the ``__yamdl__`` attribute to the models you want to use static\ncontent. A model can only be static or dynamic, not both::\n\n class MyModel(models.Model):\n ...\n __yamdl__ = True\n\nThen, start making static files under one of the directories you listed in the\n``YAMDL_DIRECTORIES`` setting above. Within one of these, make a directory with\nthe format ``appname.modelname``, and then YAML files ending in ``.yaml``::\n\n andrew-site/\n content/\n speaking.Talk/\n 2017.yaml\n 2016.yaml\n\nWithin those YAML files, you can define either a list of model instances, like\nthis::\n\n - title: 'Alabama'\n section: us-states\n\n - title: 'Alaska'\n section: us-states\n done: 2016-11-18\n place_name: Fairbanks\n\n - title: 'Arizona'\n section: us-states\n done: 2016-05-20\n place_name: Flagstaff\n\nOr a single model instance at the top level, like this::\n\n conference: DjangoCon AU\n title: Horrors of Distributed Systems\n when: 2017-08-04\n description: Stepping through some of the myriad ways in which systems can fail that programmers don't expect, and how this hostile environment affects the design of distributed systems.\n city: Melbourne\n country: AU\n slides_url: https://speakerdeck.com/andrewgodwin/horrors-of-distributed-systems\n video_url: https://www.youtube.com/watch?v=jx1Hkxe64Xs\n\nWhen you start up Django, as either ``runserver`` or in production, it will read the\nYAML files and load them into an in-memory database and then let you query them\nusing all the standard ORM stuff.\n\n\nTodo\n----\n\nHere's a short list of things I'd like to get done before a 1.0:\n\n* Maybe replace the ``__yamdl__`` attribute with something nicer.\n* Support for Python versions before 3.4, either by using a global SQLite ``:memory:`` instance with thread locking or by supporting disk databases with a wipe phase.\n* Include YAML files in the Django auto-reloader so editing them loads changes in development.\n* Potentially load changes to flat files in production using mtime checking.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/andrewgodwin/yamdl/", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "yamdl", "package_url": "https://pypi.org/project/yamdl/", "platform": "", "project_url": "https://pypi.org/project/yamdl/", "project_urls": { "Homepage": "http://github.com/andrewgodwin/yamdl/" }, "release_url": "https://pypi.org/project/yamdl/0.9.1/", "requires_dist": null, "requires_python": "", "summary": "Flat-file model instances for Django", "version": "0.9.1" }, "last_serial": 3108787, "releases": { "0.9": [ { "comment_text": "", "digests": { "md5": "58078eec8ed0b5edd724935c95dba598", "sha256": "4d5c385fb61e9abff55be0af789555ea98c7c4a1b857bd1dcc8925330b5a7c4b" }, "downloads": -1, "filename": "yamdl-0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "58078eec8ed0b5edd724935c95dba598", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 8348, "upload_time": "2017-08-14T19:33:05", "url": "https://files.pythonhosted.org/packages/f3/38/cbdd3b3edfd31481a5c52a578aefd6f5af1f38794bd30aa019bd79972e1d/yamdl-0.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "95aafa1ebf6cc2960e284e93ad44adad", "sha256": "e6e83461d05ca014db28bb70a4319aa2477ed5ca231e0fbe277f00bf444c3054" }, "downloads": -1, "filename": "yamdl-0.9.tar.gz", "has_sig": false, "md5_digest": "95aafa1ebf6cc2960e284e93ad44adad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5138, "upload_time": "2017-08-14T19:33:04", "url": "https://files.pythonhosted.org/packages/a2/b0/8eb3e7b6e887a59dceef28e3b0d5e2c6216ca146b857beb5411473a1c538/yamdl-0.9.tar.gz" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "0fce4a5e28fe0a04b388e945b2fc8131", "sha256": "483eb7f3a881dcb815bc910297d17609aea707edb7d7ef48dcf7b5831ddb716e" }, "downloads": -1, "filename": "yamdl-0.9.1-py2-none-any.whl", "has_sig": false, "md5_digest": "0fce4a5e28fe0a04b388e945b2fc8131", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8868, "upload_time": "2017-08-20T01:25:56", "url": "https://files.pythonhosted.org/packages/f3/eb/3c12b0ed0844f09527c648971435f90a6990faf6054f64d40670b141a45d/yamdl-0.9.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7599975385bf173a55eac3e8299e168b", "sha256": "22909354c8ec90a3dfd7b60a2488c909a5c9c7bb6f698a33bc06089c09a8037b" }, "downloads": -1, "filename": "yamdl-0.9.1.tar.gz", "has_sig": false, "md5_digest": "7599975385bf173a55eac3e8299e168b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5478, "upload_time": "2017-08-20T01:25:54", "url": "https://files.pythonhosted.org/packages/5b/e8/8d6e0c17be40c961f6e1bb4b6025d347474f44512d8ac5258c8aa2954752/yamdl-0.9.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0fce4a5e28fe0a04b388e945b2fc8131", "sha256": "483eb7f3a881dcb815bc910297d17609aea707edb7d7ef48dcf7b5831ddb716e" }, "downloads": -1, "filename": "yamdl-0.9.1-py2-none-any.whl", "has_sig": false, "md5_digest": "0fce4a5e28fe0a04b388e945b2fc8131", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8868, "upload_time": "2017-08-20T01:25:56", "url": "https://files.pythonhosted.org/packages/f3/eb/3c12b0ed0844f09527c648971435f90a6990faf6054f64d40670b141a45d/yamdl-0.9.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7599975385bf173a55eac3e8299e168b", "sha256": "22909354c8ec90a3dfd7b60a2488c909a5c9c7bb6f698a33bc06089c09a8037b" }, "downloads": -1, "filename": "yamdl-0.9.1.tar.gz", "has_sig": false, "md5_digest": "7599975385bf173a55eac3e8299e168b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5478, "upload_time": "2017-08-20T01:25:54", "url": "https://files.pythonhosted.org/packages/5b/e8/8d6e0c17be40c961f6e1bb4b6025d347474f44512d8ac5258c8aa2954752/yamdl-0.9.1.tar.gz" } ] }