{ "info": { "author": "Omar Shaban", "author_email": "o.shaban.000@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries" ], "description": "object-graph-builder\n====================\n\n.. image:: https://img.shields.io/pypi/v/object-graph-builder.svg\n :target: https://pypi.org/project/object-graph-builder/\n :alt: Latest Version\n\n.. image:: https://coveralls.io/repos/github/eshta/object-graph-builder/badge.svg\n :target: https://coveralls.io/github/eshta/object-graph-builder\n :alt: Coverage Status\n\n.. image:: https://readthedocs.org/projects/object-graph-builder/badge/?version=latest\n :target: https://object-graph-builder.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n.. image:: https://travis-ci.org/eshta/object-graph-builder.svg?branch=master\n :target: https://travis-ci.org/eshta/object-graph-builder\n\n\n\nProvides a multi-step dependency injection container builder to allow adding/recreating object graphs in different stages through an app life-cycle\n\nFeatures\n--------\n\n* Offering a container builder, so one can dynamically build the object graph with many apps adding their specs, classes, modules\n* Dependency Injection Container (`pinject `_)\n\n\nRequirements\n------------\n\n* Python 3.6+\n\n\nUsage\n-----\n\n1. Framework Agnostic App\n=========================\n**In container.py**\n\n.. code-block:: python\n\n import object_graph.builder\n\n builder = object_graph.builder.ObjectGraphBuilder()\n\n\n**App 1**\n\n.. code-block:: python\n\n import container\n import pinject\n\n\n class MyService(object):\n\t def __init__(long_name: SomeReallyLongClassName):\n\t\t self.my_dep = long_name\n\n class MyBindingSpec(pinject.BindingSpec):\n\t def configure(self, bind):\n\t\t bind('long_name', to_class=SomeReallyLongClassName)\n\n container.builder.addBindingSpec(MyBindingSpec)\n\n**App 2**\n\n.. code-block:: python\n\n import container\n\n\n container.builder.addModules([app2.module1, app2.module2])\n\n**Client**\n\n.. code-block:: python\n\n import container\n\n object_graph = container.builder.get_object_graph()\n\n my_service = object_graph.provide(MyService)\n\n\n2. Django Example\n=================\n\nOne can define the builder in your settings.py and then import it\nin each app and add the configurations you need\n\n**In settings.py**\n\n.. code-block:: python\n\n import object_graph.builder\n\n object_graph_builder = object_graph.builder.ObjectGraphBuilder()\n\n\n**App 1** in apps.App1Config.ready()\n\n.. code-block:: python\n\n from config.settings import object_graph_builder\n import pinject\n\n\n class MyService(object):\n\t def __init__(long_name: SomeReallyLongClassName):\n\t\t self.my_dep = long_name\n\n class MyBindingSpec(pinject.BindingSpec):\n\t def configure(self, bind):\n\t\t bind('long_name', to_class=SomeReallyLongClassName)\n\n object_graph_builder.addBindingSpec(MyBindingSpec)\n\n**App 2**\nin apps.App2Config.ready()\n\n.. code-block:: python\n\n from config.settings import object_graph_builder\n\n\n object_graph_builder.addModules([app2.module1, app2.module2])\n\n**Client**\n\n.. code-block:: python\n\n object_graph = object_graph_builder.get_object_graph()\n\n my_service = object_graph.provide(MyService)\n\n\nEach time you call *object_graph_builder.get_object_graph()*, it will check if it needs to rebuild the object graph.\n\n\nPrepare for development\n-----------------------\n\nA Python 3.6+ interpreter is required in addition to pipenv.\n\n.. code-block:: bash\n\n $ make init\n\n\nNow you're ready to run the tests:\n\n.. code-block:: bash\n\n $ make test\n\n\nResources\n---------\n\n* `Documentation `_\n* `Bug Tracker `_\n* `Code `_", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/eshta/object-graph-builder", "keywords": "Dependency injection,dependency-injection,dependency-injection-container,dependency-injection-framework,design-patterns,factory,ioc,ioc-container,python,pinject,singleton", "license": "", "maintainer": "", "maintainer_email": "", "name": "object-graph-builder", "package_url": "https://pypi.org/project/object-graph-builder/", "platform": "", "project_url": "https://pypi.org/project/object-graph-builder/", "project_urls": { "Homepage": "https://github.com/eshta/object-graph-builder" }, "release_url": "https://pypi.org/project/object-graph-builder/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "Provides an interface to build the dependency injection container.", "version": "0.0.2" }, "last_serial": 5441235, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "6229b7c0b8db0464473795408e2b3007", "sha256": "2c8f054a1e7f317c2e332a4ba5cddb8afd59230582fd2871a26088b839d9a401" }, "downloads": -1, "filename": "object-graph-builder-0.0.2.tar.gz", "has_sig": false, "md5_digest": "6229b7c0b8db0464473795408e2b3007", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4508, "upload_time": "2019-06-24T15:44:43", "url": "https://files.pythonhosted.org/packages/2e/df/c74c38afa6fe975846fe213260b12a980952f6236ef9d2478538e68c9ece/object-graph-builder-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6229b7c0b8db0464473795408e2b3007", "sha256": "2c8f054a1e7f317c2e332a4ba5cddb8afd59230582fd2871a26088b839d9a401" }, "downloads": -1, "filename": "object-graph-builder-0.0.2.tar.gz", "has_sig": false, "md5_digest": "6229b7c0b8db0464473795408e2b3007", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4508, "upload_time": "2019-06-24T15:44:43", "url": "https://files.pythonhosted.org/packages/2e/df/c74c38afa6fe975846fe213260b12a980952f6236ef9d2478538e68c9ece/object-graph-builder-0.0.2.tar.gz" } ] }