{ "info": { "author": "Bay Citizen & Texas Tribune", "author_email": "dev@armstrongcms.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7" ], "description": "armstrong.utils.backends\n========================\n\n.. image:: https://travis-ci.org/armstrong/armstrong.utils.backends.svg?branch=master\n :target: https://travis-ci.org/armstrong/armstrong.utils.backends\n :alt: TravisCI status\n.. image:: https://coveralls.io/repos/armstrong/armstrong.utils.backends/badge.png\n :target: https://coveralls.io/r/armstrong/armstrong.utils.backends\n :alt: Coverage status\n.. image:: https://pypip.in/version/armstrong.utils.backends/badge.png\n :target: https://pypi.python.org/pypi/armstrong.utils.backends/\n :alt: PyPI Version\n.. image:: https://pypip.in/license/armstrong.utils.backends/badge.png\n :target: https://pypi.python.org/pypi/armstrong.utils.backends/\n :alt: License\n\nGeneric backend system to use throughout Armstrong\n\n\nUsage\n-----\nDynamically load a Python module at runtime and use it as if you'd hardcoded\nthe module directly. This allows flexibility. It's polymorphism in action.\n\nWhy? In the Armstrong internals we do a bunch of stuff via backends. If you\nwant to do that stuff differently, make a class with the same interface and\nprovide your class as the backend. Armstrong will work *its* magic the way\n*you* want. In many cases, Armstrong ships with support for multiple common\nscenarios (implemented as backends) and you can pick the one that fits your\nneeds.\n\nFollowing the Django paradigm, create a ``key = value`` in ``setttings.py``\nwhere the value is a string or a list of strings of full, dotted, Python\nimport paths. That module will be imported at runtime and used *exactly*\nas if you had instantiated it directly. An example::\n\n # hello/world.py\n class Hello(object):\n def hi(self):\n print(\"Hello world!\")\n\n # hello/armstrong.py\n class Hello(object):\n def hi(self):\n print(\"Hello Armstrong!\")\n\n # settings.py <-- armstrong.utils.backends uses Django settings by default\n HELLO_CLASS = \"hello.armstrong.Hello\"\n\n # somewhere_else.py or in a console\n >>> from armstrong.utils.backends import GenericBackend\n >>> hello = GenericBackend(\"HELLO_CLASS\").get_backend()\n >>> hello.hi()\n Hello Armstrong!\n\nA **default** can be provided and the process works like the standard Python\ndict.get() where if the key doesn't exist in the settings, there's a fallback.\n(This is how Armstrong specifies its defaults so you aren't required to change\nyour settings.py if satisfied with the default behavior.)::\n\n >>> backend = GenericBackend(\"MISSING_KEY\", defaults=\"hello.world.Hello\")\n >>> hello = backend.get_backend()\n >>> hello.hi()\n Hello world!\n\nCalling ``get_backend()`` is the equivalent of instantiation. So whenever\nyou're ready to use the dynamically loaded class, call ``get_backend``.\nPass in any parameters you'd normally use. Think of it as ``__init__``.\nThese are the same::\n\n GenericBackend(\"HELLO_CLASS\").get_backend(1, two=2)\n Hello(1, two=2)\n\nYou can pass in a **different settings** module with the ``settings`` kwarg if you\nwant the backend loader to look somewhere other than Django settings.\n\nMultiple backends\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\nAnother powerful feature? Feeding in multiple possible backends. Armstrong\nwill perform the action you want by going down the list of backends stopping\nat the first one that does its job. If the backend's method raises a\n``BackendDidNotHandle`` exception, Armstrong will try the next backend.\nA pseudo code example::\n\n default_backends = [\"myapp.backends.TwitterBackend\",\n \"myapp.backends.FacebookBackend\"]\n backend = GenericBackend(\"SOCIAL_NETWORKS\", defaults=default_backends)\n\n # myapp.backends.py\n class TwitterBackend(object):\n def post(msg):\n if not self.user.has_account:\n raise BackendDidNotHandle(\"No account for that user\")\n\n social_network = backend.get_backend(user)\n social_network.post(\"Armstrong is pretty sweet you guys\")\n\n\nWriting Backends\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\nBackends are classes. ``GenericBackend`` is a way to dynamically load those\nclasses. Beyond using ``get_backend`` to handle the creation of the backend,\nyou treat it as if you were calling it directly.\n\nIf you are using multiple backends, all attributes (and methods) accessed on\nthe backend are proxied to handle the dispatching. To have a backend abdicate\nand have the loader use the next backend in the list, have the backend\nmethod raise ``armstrong.utils.backends.BackendDidNotHandle``.\n\n\nInstallation & Configuration\n----------------------------\nSupports Django 1.3, 1.4, 1.5, 1.6, 1.7 on Python 2.6 and 2.7.\n\n#. ``pip install armstrong.utils.backends``\n\n\nContributing\n------------\nDevelopment occurs on Github. Participation is welcome!\n\n* Found a bug? File it on `Github Issues`_. Include as much detail as you\n can and make sure to list the specific component since we use a centralized,\n project-wide issue tracker.\n* Testing? ``pip install tox`` and run ``tox``\n* Have code to submit? Fork the repo, consolidate your changes on a topic\n branch and create a `pull request`_. The `armstrong.dev`_ package provides\n tools for testing, coverage and South migration as well as making it very\n easy to run a full Django environment with this component's settings.\n* Questions, need help, discussion? Use our `Google Group`_ mailing list.\n\n.. _Github Issues: https://github.com/armstrong/armstrong/issues\n.. _pull request: http://help.github.com/pull-requests/\n.. _armstrong.dev: https://github.com/armstrong/armstrong.dev\n.. _Google Group: http://groups.google.com/group/armstrongcms\n\n\nState of Project\n----------------\n`Armstrong`_ is an open-source news platform that is freely available to any\norganization. It is the result of a collaboration between the `Texas Tribune`_\nand `Bay Citizen`_ and a grant from the `John S. and James L. Knight\nFoundation`_. Armstrong is available as a complete bundle and as individual,\nstand-alone components.\n\n.. _Armstrong: http://www.armstrongcms.org/\n.. _Bay Citizen: http://www.baycitizen.org/\n.. _Texas Tribune: http://www.texastribune.org/\n.. _John S. and James L. Knight Foundation: http://www.knightfoundation.org/\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/armstrong/armstrong.utils.backends/", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "armstrong.utils.backends", "package_url": "https://pypi.org/project/armstrong.utils.backends/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/armstrong.utils.backends/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/armstrong/armstrong.utils.backends/" }, "release_url": "https://pypi.org/project/armstrong.utils.backends/1.1.1/", "requires_dist": null, "requires_python": null, "summary": "Generic backend system to use throughout Armstrong", "version": "1.1.1" }, "last_serial": 1216644, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "82178b489afb93134953ee508ff91f6a", "sha256": "a61015ddfdc6fd1b2a6978c6e581b0bbe708fa727ba31589a859bcb545477335" }, "downloads": -1, "filename": "armstrong.utils.backends-0.1.0.tar.gz", "has_sig": false, "md5_digest": "82178b489afb93134953ee508ff91f6a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6420, "upload_time": "2011-06-24T19:36:25", "url": "https://files.pythonhosted.org/packages/01/78/6fd0d3085b704a808da4cd18ec528cf0f735a9bed85da64ffc53e52b7b33/armstrong.utils.backends-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "990442534f2b92df00ddc527e8d5a412", "sha256": "4d0fc7800fb0fc24691a1fa350136bed7315ff25de858e6cb9b298b3f1aa557f" }, "downloads": -1, "filename": "armstrong.utils.backends-0.1.1.tar.gz", "has_sig": false, "md5_digest": "990442534f2b92df00ddc527e8d5a412", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6379, "upload_time": "2011-06-28T06:18:59", "url": "https://files.pythonhosted.org/packages/32/d9/58d6715e9f510a1ea10deddff3178c1f44e99608296248dd6918bfaaf675/armstrong.utils.backends-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "d151067bef43b08459de1aa4c93261e9", "sha256": "31ed01fb8f34a03f3fd204cbfa692962fac9e35c04de9e1ea64e35869c67fa29" }, "downloads": -1, "filename": "armstrong.utils.backends-0.2.0.tar.gz", "has_sig": false, "md5_digest": "d151067bef43b08459de1aa4c93261e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6614, "upload_time": "2011-06-30T20:02:27", "url": "https://files.pythonhosted.org/packages/f9/3f/072838e8a08b4ebbc28ca86a8c66dd078af9a2fad11af1dfc4614d68a8a5/armstrong.utils.backends-0.2.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "ad30c3e216234193f6a888aead31f675", "sha256": "fee088b855c5e6887c75c12713383e1461ef2ae9f12cb8c30fa7cda2f6ac3d6c" }, "downloads": -1, "filename": "armstrong.utils.backends-1.0.0.tar.gz", "has_sig": false, "md5_digest": "ad30c3e216234193f6a888aead31f675", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6742, "upload_time": "2011-09-30T22:33:03", "url": "https://files.pythonhosted.org/packages/9c/57/5bbd388c7073616abc051f35a64efceeb7f3ca4d04bc9adb952bf41baa19/armstrong.utils.backends-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "b5291dd1ac330c25baa8252275e3533c", "sha256": "5b0eee4661cab0f3472564dfdac3668625fccfeb64fdc7b32cf1840b103b97d1" }, "downloads": -1, "filename": "armstrong.utils.backends-1.1.0.tar.gz", "has_sig": false, "md5_digest": "b5291dd1ac330c25baa8252275e3533c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9109, "upload_time": "2014-09-06T03:10:32", "url": "https://files.pythonhosted.org/packages/7b/e2/71b0e357846951de57a094df05d6cf1fc3fe556f5fbd0a02960c29baf7ae/armstrong.utils.backends-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "a7d1544fe015503d36fbf257c0475268", "sha256": "dd3a154e24ba2330b74e89044466d18a3b14cb9c731fad0127ea9afd605be0d9" }, "downloads": -1, "filename": "armstrong.utils.backends-1.1.1.tar.gz", "has_sig": false, "md5_digest": "a7d1544fe015503d36fbf257c0475268", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9165, "upload_time": "2014-09-08T05:14:05", "url": "https://files.pythonhosted.org/packages/ec/c4/dd983137499a67740ea1404160e5e1c2b7bcdb542c33d9ccae19d417a7f6/armstrong.utils.backends-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a7d1544fe015503d36fbf257c0475268", "sha256": "dd3a154e24ba2330b74e89044466d18a3b14cb9c731fad0127ea9afd605be0d9" }, "downloads": -1, "filename": "armstrong.utils.backends-1.1.1.tar.gz", "has_sig": false, "md5_digest": "a7d1544fe015503d36fbf257c0475268", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9165, "upload_time": "2014-09-08T05:14:05", "url": "https://files.pythonhosted.org/packages/ec/c4/dd983137499a67740ea1404160e5e1c2b7bcdb542c33d9ccae19d417a7f6/armstrong.utils.backends-1.1.1.tar.gz" } ] }