{ "info": { "author": "Zachary Sims", "author_email": "zsims@users.noreply.github.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries :: Application Frameworks" ], "description": "dic\n===\n\nDependency Injection Container for Python 3+ influenced partially by Autofac_. dic aims to be a tiny \"out of the way\" framework to help\nrealise IoC via dependency injection. dic uses Python 3 annotations to provide hints for the components that should be injected.\n\n|version| |build| |docs|\n\nDocumentation\n=============\ndic documentation is available via `Read the Docs`_.\n\nInstall\n=======\ndic is available via pip:\n ::\n\n pip install dic\n\nFeatures\n========\nCurrently, dic supports:\n\n1. Constructor injection for classes\n2. Factory and Lazy relationships\n3. Registration via:\n 1. Constructor matching for a registered class\n 2. Custom callback\n 3. Pre-created instances\n4. Lifetime scopes:\n 1. Instance per dependency\n 2. Single instance\n \nQuick Example\n=============\nA quick example on how to use dic:\n ::\n\n import dic\n\n class SimpleThing(object):\n def say(self, message):\n print(message)\n\n class RequiresThing(object):\n def __init__(self, thing: SimpleThing):\n self.thing = thing\n\n def say(self, message):\n self.thing.say(message)\n\n # build the container\n builder = dic.container.ContainerBuilder()\n\n builder.register_class(SimpleThing)\n builder.register_class(RequiresThing, component_scope=dic.scope.SingleInstance)\n\n container = builder.build()\n\n # use the container\n\n # Note there'll only be one of these due to SingleInstance scoping during build\n x = container.resolve(RequiresThing)\n x.say(\"my message\")\n\nRelationships\n=============\ndic supports basic relationships:\n\n1. `dic.rel.Lazy` - don't create the dependency until it's first used\n2. `dic.rel.Factory` - the component wants to create other components. Lifetime scopes are respected. Supports custom arguments.\n\nUsing a factory:\n ::\n\n import dic\n\n class SimpleThing(object):\n def __init__(self, special_argument):\n self.special_argument = special_argument\n\n class BuildsThings(object):\n def __init__(self, thing_factory: dic.rel.Factory(SimpleThing)):\n self.thing_factory = thing_factory\n\n def build_me_a_thing(self):\n # builds a new thing using the injected factory\n # Note that custom arguments can be provided here\n self.thing_factory(special_argument=\"My super special argument\")\n\n # build the container\n builder = dic.container.ContainerBuilder()\n\n builder.register_class(SimpleThing)\n builder.register_class(BuildsThing)\n\n container = builder.build()\n\n # use the container\n\n x = container.resolve(BuildsThing)\n\n # use it\n thing = x.build_me_a_thing()\n # ...\n\n\nFAQ\n===\n\n1. Is dic thread-safe?\n\n Yes. `dic.rel.Lazy` and `dic.container.Container.resolve()` are thread-safe. As a result, do not store the component_context given to `register_callback` callbacks,\n as thread-safety is enforced at the container.resolve() level.\n\n2. Can I define my own scopes?\n\n Yes. Derive a scope from `dic.scope.Scope`. Scopes can be used to provide lifetime for a calling thread, for example\n\n\n.. _Autofac: http://autofac.org/\n.. _`Read the Docs`: http://dic.readthedocs.org/\n.. |version| image:: https://pypip.in/version/dic/badge.svg?text=version\n :target: https://pypi.python.org/pypi/dic\n.. |docs| image:: https://readthedocs.org/projects/dic/badge/?version=latest\n :target: https://readthedocs.org/projects/dic/\n.. |build| image:: https://travis-ci.org/zsims/dic.svg?branch=master\n :target: https://travis-ci.org/zsims/dic", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/zsims/dic", "keywords": "development design ioc di", "license": "LICENSE.txt", "maintainer": null, "maintainer_email": null, "name": "dic", "package_url": "https://pypi.org/project/dic/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dic/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/zsims/dic" }, "release_url": "https://pypi.org/project/dic/1.5.2b1/", "requires_dist": null, "requires_python": null, "summary": "Dependency Injection Container for Python 3+. Uses Python 3 annotations to provide hints for the components that should be injected.", "version": "1.5.2b1" }, "last_serial": 1373819, "releases": { "1.2.0b1": [ { "comment_text": "", "digests": { "md5": "034253c3e03f5155a91ee96c20ccd2a9", "sha256": "a81d8f17af85e7c777630c5c6b89de9779537de1ace77656d231ef99bdf5f49a" }, "downloads": -1, "filename": "dic-1.2.0b1.tar.gz", "has_sig": false, "md5_digest": "034253c3e03f5155a91ee96c20ccd2a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5631, "upload_time": "2014-12-20T22:21:57", "url": "https://files.pythonhosted.org/packages/00/f1/e527b473ec94a33e98273080fd7bf66227c1dee477a1d1bee0977f0431a1/dic-1.2.0b1.tar.gz" } ], "1.3.0b1": [ { "comment_text": "", "digests": { "md5": "4ccbda9a587d3cf2ae2c1de38697ec70", "sha256": "c8a7518bb84a38c379ffe6bef3d8232f09d5c6d5d8e90bf2a9f5bf23318c7995" }, "downloads": -1, "filename": "dic-1.3.0b1.tar.gz", "has_sig": false, "md5_digest": "4ccbda9a587d3cf2ae2c1de38697ec70", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6026, "upload_time": "2014-12-21T09:50:26", "url": "https://files.pythonhosted.org/packages/f2/87/7482392f6552e9fd11fd39e0370903e7ad572076a0655a2bafb48553bfee/dic-1.3.0b1.tar.gz" } ], "1.4.0b1": [ { "comment_text": "", "digests": { "md5": "94711a1c471a37a5f4826a161ed282ff", "sha256": "86c6ec2b0d20b47abe93f6e83560e86cbaa87bffaa33ba7caf587bbfda0ddb36" }, "downloads": -1, "filename": "dic-1.4.0b1.tar.gz", "has_sig": false, "md5_digest": "94711a1c471a37a5f4826a161ed282ff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6363, "upload_time": "2014-12-21T11:56:44", "url": "https://files.pythonhosted.org/packages/53/76/c94b3834b9827691a0c6057c3eb08304a49edf5781ac9c354787d420babd/dic-1.4.0b1.tar.gz" } ], "1.5.0b1": [ { "comment_text": "", "digests": { "md5": "c97149fa6691d1e964f5756cd03af0ec", "sha256": "dfd3d5f7014e3798889d817a01a099c22e026eb0ab47be439d55d11f97edc72d" }, "downloads": -1, "filename": "dic-1.5.0b1.tar.gz", "has_sig": false, "md5_digest": "c97149fa6691d1e964f5756cd03af0ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6695, "upload_time": "2014-12-22T10:13:57", "url": "https://files.pythonhosted.org/packages/f4/19/feff74c050801cce8c193841d16af11076907eae78eb53e94e8f734576c6/dic-1.5.0b1.tar.gz" } ], "1.5.1b1": [ { "comment_text": "", "digests": { "md5": "60799c119251e4e11a1a6c9e8206bcc5", "sha256": "1df37142e02fe1aeeae50d344a20fc18d7e85035ddea4e31e1e2595326530b35" }, "downloads": -1, "filename": "dic-1.5.1b1.tar.gz", "has_sig": false, "md5_digest": "60799c119251e4e11a1a6c9e8206bcc5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6908, "upload_time": "2014-12-22T10:41:11", "url": "https://files.pythonhosted.org/packages/38/0d/434a0267838ef57e32daee17a661d106fddd0de5d7f96e05471aaaf379e4/dic-1.5.1b1.tar.gz" } ], "1.5.2b1": [ { "comment_text": "", "digests": { "md5": "b3b66ce93a3a285eb94040165771b879", "sha256": "f0d2ce490e5975fe73239a0f7c61f252d204e9986547ea1a75456a0873cc2836" }, "downloads": -1, "filename": "dic-1.5.2b1.tar.gz", "has_sig": false, "md5_digest": "b3b66ce93a3a285eb94040165771b879", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7282, "upload_time": "2015-01-04T07:21:11", "url": "https://files.pythonhosted.org/packages/5e/9e/0414910d4947e69662c9c10c1ca8c824ad34c85f9402c03998cea8a936c2/dic-1.5.2b1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b3b66ce93a3a285eb94040165771b879", "sha256": "f0d2ce490e5975fe73239a0f7c61f252d204e9986547ea1a75456a0873cc2836" }, "downloads": -1, "filename": "dic-1.5.2b1.tar.gz", "has_sig": false, "md5_digest": "b3b66ce93a3a285eb94040165771b879", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7282, "upload_time": "2015-01-04T07:21:11", "url": "https://files.pythonhosted.org/packages/5e/9e/0414910d4947e69662c9c10c1ca8c824ad34c85f9402c03998cea8a936c2/dic-1.5.2b1.tar.gz" } ] }