{ "info": { "author": "keno", "author_email": "keno.ss57@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3 :: Only", "Topic :: Utilities" ], "description": "Dicon, simple DI container injection liblary for Python.\n\n---\n\nDicon is a simple \"DI container injection\" library.\n\n## FAQ\n\n- Q. Is `dicon` a dependency injection library?\n- A. No, it does not support dependency injection. It supports DI container injection and service (singleton) locator.\n\n## Important points\n\n- Simple to use.\n- Clear what it does on each stage.\n- Small overhead.\n\n## Features\n\n- `@dicon.inject_di_container` class decorator supports nested DI container injection, without modification on type.\n- `dicon.DIContainer` provides class resolver and singleton locating.\n\n### Class resolver, no modification on type\n\n```python\nimport dicon\n\nclass A:\n pass\n\ndi_container = dicon.DIContainer()\ndi_container.register[A]()\ndi_container.freeze()\n\n# Resolve class.\nclass_A = di_container.resolve[A]\na = class_A()\n# dicon.DIContainer does not modify type of the object.\nassert type(a) is A\n# It only modifies constructor. (Normally it will be not a problem.)\nassert not (class_A is A)\n```\n\n### Nested DI container injection\n\n```python\n@dicon.inject_di_container('_di_container')\nclass B:\n _di_container = None # Here we get instance of DIContainer.\n\n def __init__(self, message):\n print(message, self._di_container)\n\n@dicon.inject_di_container('_di_container')\nclass C:\n _di_container = None # Here we get instance of DIContainer.\n\n def __init__(self):\n self._b = self._di_container.resolve[B]('B must be have DIContainer:')\n\ndi_container = dicon.DIContainer()\ndi_container.register[B]()\ndi_container.register[C]()\ndi_container.freeze()\n\ndi_container.resolve[C]()\n# will print 'B must be have DIContainer: ...'\n```\n\n### Singleton locating\n\nTBW...\n\n## How it works\n\n1. `@dicon.inject_di_container` modifies `__init__` of given class to make it possible `__init__` can take DIContainer as an argument.\n2. `DIContainer.resolve` ties itself to that argument by `functools.partial`.\n\nThat's all.\n\nFor more details, see [tests](tests).\n\n## Other existing solutions\n\n- Dependency injection\n - There are lots of DI libraries: for example, [injector](https://github.com/alecthomas/injector), [pinject](https://github.com/google/pinject).\n - IMHO, DI is too complex for python.\n - Famous liblaries are too complex and not clear how affect to the program.\n - It seems no one support nested injection.\n- Service locator\n - [wired](https://github.com/mmerickel/wired)\n - I personally felt it is too complex.\n - [factoryfactory](https://github.com/jammycakes/factoryfactory)\n - It does not support multiple service locators.\n\nI borrowed design of [MicroResolver](https://github.com/neuecc/MicroResolver) in API.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kenoss/dicon", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "dicon", "package_url": "https://pypi.org/project/dicon/", "platform": "", "project_url": "https://pypi.org/project/dicon/", "project_urls": { "Homepage": "https://github.com/kenoss/dicon" }, "release_url": "https://pypi.org/project/dicon/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Dicon, simple DI container injection liblary for Python.", "version": "0.0.3" }, "last_serial": 4331119, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "5fefcde92a598b879e18d5348b2c726a", "sha256": "cbe4cba051bdd931fb338096cff4c5316ff2e47a28c934c5e9859929b5e013de" }, "downloads": -1, "filename": "dicon-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5fefcde92a598b879e18d5348b2c726a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4550, "upload_time": "2018-09-24T19:12:35", "url": "https://files.pythonhosted.org/packages/ed/ac/fcaa8fdda4619cda04cbd7c46dd44479d0eeecd714c012a51ff071dc26dd/dicon-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5ccf806836e2eed5f588b56af72c9927", "sha256": "451df5490cb8d2f02c23bb2fe259b4ce5467214356a23d061cb583813f1af95e" }, "downloads": -1, "filename": "dicon-0.0.1.tar.gz", "has_sig": false, "md5_digest": "5ccf806836e2eed5f588b56af72c9927", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5027, "upload_time": "2018-09-24T19:12:36", "url": "https://files.pythonhosted.org/packages/84/17/304d2053695c60da3e22f4ea1e37c9fa28eba06c1dfd3e69f483345f7341/dicon-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "b448cc937ba3422d3b0e125cb03607a0", "sha256": "ba74e068a67ebca106dfc9748cb8d26d4814e0523e6e5aef7f6d56f67a024a2c" }, "downloads": -1, "filename": "dicon-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b448cc937ba3422d3b0e125cb03607a0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4540, "upload_time": "2018-10-01T01:41:15", "url": "https://files.pythonhosted.org/packages/4a/e1/7109b4a1b4de91fac784a64f6bd635da75c23e7e4aa5c679070e8be25d57/dicon-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "387be8fe5f717c4e41b49b59761c90c1", "sha256": "5924a83c710a0f1b3f35a0e3082eb0aa3a379b3888f65eb36e721e3fc5d6f63b" }, "downloads": -1, "filename": "dicon-0.0.2.tar.gz", "has_sig": false, "md5_digest": "387be8fe5f717c4e41b49b59761c90c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7869, "upload_time": "2018-10-01T01:41:17", "url": "https://files.pythonhosted.org/packages/5a/80/571a9f4bca2e3b5a7dd3e250cf1d647d74e78a3eaaf32db8d01e180addb8/dicon-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "6f9557fdab7e961ae7e3c251aba0628a", "sha256": "035d559875dde50429c10fd8b04250eb90a8cf8ad1abb97724161ad74a552f09" }, "downloads": -1, "filename": "dicon-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "6f9557fdab7e961ae7e3c251aba0628a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4593, "upload_time": "2018-10-02T03:26:02", "url": "https://files.pythonhosted.org/packages/16/85/c9361a94b3747a2c8e22c75be866e7db62f78d0be01c6581a872c8d93a22/dicon-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a95a76422d69381eb108201ae0d7fca9", "sha256": "30fbb747c8e17b0150032e85c2b20cbcee8e84153b6dbfbbfc8d3e368f663973" }, "downloads": -1, "filename": "dicon-0.0.3.tar.gz", "has_sig": false, "md5_digest": "a95a76422d69381eb108201ae0d7fca9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8146, "upload_time": "2018-10-02T03:26:03", "url": "https://files.pythonhosted.org/packages/fc/03/19acbd77ecc17b345b33232ab69fad7190cbe031eadbf795954f85e5c2ec/dicon-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6f9557fdab7e961ae7e3c251aba0628a", "sha256": "035d559875dde50429c10fd8b04250eb90a8cf8ad1abb97724161ad74a552f09" }, "downloads": -1, "filename": "dicon-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "6f9557fdab7e961ae7e3c251aba0628a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4593, "upload_time": "2018-10-02T03:26:02", "url": "https://files.pythonhosted.org/packages/16/85/c9361a94b3747a2c8e22c75be866e7db62f78d0be01c6581a872c8d93a22/dicon-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a95a76422d69381eb108201ae0d7fca9", "sha256": "30fbb747c8e17b0150032e85c2b20cbcee8e84153b6dbfbbfc8d3e368f663973" }, "downloads": -1, "filename": "dicon-0.0.3.tar.gz", "has_sig": false, "md5_digest": "a95a76422d69381eb108201ae0d7fca9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8146, "upload_time": "2018-10-02T03:26:03", "url": "https://files.pythonhosted.org/packages/fc/03/19acbd77ecc17b345b33232ab69fad7190cbe031eadbf795954f85e5c2ec/dicon-0.0.3.tar.gz" } ] }