{
"info": {
"author": "",
"author_email": "",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Topic :: Software Development :: Libraries :: Application Frameworks"
],
"description": "Weedi\n=====\n\n|Build Status|\n\nIntroduction\n------------\n\nWeedi is a dependency injection container based on\n`setuptools `__ and `entry\npoints `__.\n\nIt was first developed by [@Net-ng](https://github.com/Net-ng) and later\nopensourced and maintained by Weenect.\n\nIt is tested for python's versions 2.7, 3.3, 3.4 and 3.5\n\nInstallation\n------------\n\nYou will need to have ``setuptools`` installed and to use it in your\nproject as weedi uses the ``entry_points`` feature.\n\nYou can add ``weedi`` as a dependency of your project in your setup.py :\n\n.. code:: python\n\n from setuptools import setup, find_packages\n\n setup(\n ...\n install_requires=('weedi'),\n ...\n )\n\nThen run ``python setup.py install`` or ``python setup.py develop``\n\nUsage\n-----\n\nLet's suppose you are managing locators and you have a service\nLocatorManager which depends on the database.\n\nYou will have these class in a module ``services.py`` :\n\n.. code:: python\n\n import weedi.loadable as loadable\n\n\n class Database(loadable.Service):\n spec = {\n 'host': 'string(default=\"localhost\")',\n 'port': 'integer(default=3306)',\n 'debug': 'boolean(default=False)',\n }\n\n load_priority = -10\n\n def __init__(self, host, port, debug):\n self.host = host\n self.port = port\n self.debug = debug\n\n\n class LocatorManager(loadable.Service):\n def __init__(self, database_service):\n self.db = database_service\n\nYou need to register these services in the ``entry_points`` or your\nproject ``setup.py``.\n\n.. code:: python\n\n setup(\n ...\n entry_points='''\n [services]\n database = my_project.services:Database\n manager = my_project.services:LocatorManager\n '''\n ...\n )\n\n*Note : the name of the argument in LocatorManager constructor is\ndatabase\\_service. This is the concatenation of the code of the database\nentry point and the string ``_service``. This is the way the library\nrecognizes that it needs to inject the database service when it\ninstanciates the manager service.*\n\nThen, you need to configure your container. Let's create a module\n``repository.py``. When creating a container, you need to define the\nname of the section managed by this repository in the entry points\n(here, it will be ``services``) and the name of the section in the\nconfig file for this repository (cf config.ini below, it will be\n``services`` too).\n\n.. code:: python\n\n import weedi.loadables_repository as loadables_repository\n\n\n class ServicesRepository(loadables_repository.LoadablesRepository):\n entry_point = 'services'\n conf_section = 'services'\n\nThe database service will have default value injected when it is created\nbased on its spec. You can override this by creating a config file\n``config.ini`` :\n\n.. code:: ini\n\n [services]\n\n [[database]]\n host = \"database.local\"\n port = 5432\n debug = True\n\nEverything is ready. You just have to start your container.\n\n.. code:: python\n\n service_repository = ServicesRepository()\n service_repository.load('path_to/config.ini')\n\nYou can access the services from the container :\n\n.. code:: python\n\n database_service = service_repository['database']\n locator_manager_service = service_repository['manager']\n\nYou can inject these services in an object by constructor or by method :\n\n.. code:: python\n\n class ObjectNeedsService(object):\n def __init__(self, database_service):\n self.db = database_service\n self.manager = None\n\n def set_services(self, manager_service):\n self.manager = manager_service\n\n new_instance = service_repository(ObjectNeedsService)\n assert new_instance.db == service_repository['database']\n assert new_instance.manager is None\n service_repository(new_instance.set_services)\n assert new_instance.db == service_repository['database']\n assert new_instance.manager == service_repository['manager']\n\nYou can pass arguments to the called function when using the container :\n\n.. code:: python\n\n class ObjectWithArgs(object):\n def __init__(self, param1, param2, database_service, param3=None, param4={}):\n self.db = database_service\n self.param1 = param1\n self.param2 = param2\n self.param3 = param3\n self.param4 = param4\n\n new_instance = service_repository(ObjectWithArgs, 'param1', 'param2', param4='param4')\n assert new_instance.db == service_repository['database']\n assert new_instance.param1 == 'param1'\n assert new_instance.param2 == 'param2'\n assert new_instance.param3 is None\n assert new_instance.param4 == 'param4'\n\n**The ``project`` folder is used to both run functional tests and to\nprovide examples of use cases. Don't hesitate to go see the `test\ncases `__**\n\nTroubleshooting.\n----------------\n\n- You are getting an exception ``ServiceWrongPriority`` : change the\n load\\_priority value of your services to change the order of\n instanciation. The lesser the value is, the sooner it is\n instanciated.\n\n- You are getting an exception ``ServiceMissing`` : you forgot to\n define (or mispelled) a service definition in your project entry\n points.\n\n- You are getting an exception ``WrongConfiguration`` : You are missing\n some configuration key for a service in your config file or you are\n missing a config file altogether.\n\n.. |Build Status| image:: https://travis-ci.org/weenect/weedi.svg?branch=master\n :target: https://travis-ci.org/weenect/weedi",
"description_content_type": null,
"docs_url": null,
"download_url": "https://github.com/weenect/weedi/tarball/1.0",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/weenect/weedi",
"keywords": "di,dependency injection,entry points,entry_points,setuptools",
"license": "MIT",
"maintainer": "",
"maintainer_email": "",
"name": "weedi",
"package_url": "https://pypi.org/project/weedi/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/weedi/",
"project_urls": {
"Download": "https://github.com/weenect/weedi/tarball/1.0",
"Homepage": "https://github.com/weenect/weedi"
},
"release_url": "https://pypi.org/project/weedi/1.0/",
"requires_dist": null,
"requires_python": "",
"summary": "A dependency injection system/container using setuptools entry points",
"version": "1.0"
},
"last_serial": 2350472,
"releases": {
"0.1": [
{
"comment_text": "",
"digests": {
"md5": "801d86d7af10c72e9733ef1084e5c2f3",
"sha256": "ac5c6fe10bb873f5a48ef91f7b8510732c0a676ee7bd9a0da476d3388f1a8b83"
},
"downloads": -1,
"filename": "weedi-0.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "801d86d7af10c72e9733ef1084e5c2f3",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 10262,
"upload_time": "2016-09-19T11:01:43",
"url": "https://files.pythonhosted.org/packages/88/0c/d9e6251b3b181f859a3a25c71f14bc827e2d7dc35cb8631671c9b1445bcd/weedi-0.1-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "b11d5d47a0b5052c3698d7e532c86a80",
"sha256": "af33f455691f2e13b3889f60466432545093fcd3d3c2024ed60049035c791b71"
},
"downloads": -1,
"filename": "weedi-0.1.tar.gz",
"has_sig": false,
"md5_digest": "b11d5d47a0b5052c3698d7e532c86a80",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6267,
"upload_time": "2016-09-19T10:55:21",
"url": "https://files.pythonhosted.org/packages/35/de/656479d7213c1c7109e3a631dcd32aaed5341aa0958d9766b4a729a8598e/weedi-0.1.tar.gz"
}
],
"1.0": [
{
"comment_text": "",
"digests": {
"md5": "a730c24b389cc35306ae3931b97d8759",
"sha256": "c2e0bb7afd51755b4e426952886e0296f013eb31387e98ecffc1b0cec7bc3ea5"
},
"downloads": -1,
"filename": "weedi-1.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "a730c24b389cc35306ae3931b97d8759",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 10234,
"upload_time": "2016-09-19T11:11:13",
"url": "https://files.pythonhosted.org/packages/22/78/82104779e8b737a8f53fe46481d7f6599d8bb3304d107fc1d3e0cf5804af/weedi-1.0-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "79a4527f1ce1ee9cf4d67b5d1088ff5d",
"sha256": "5b2e7df91a6b46bbba72935572a11469ba53e108b8fb6f2dc64d9424d755b30f"
},
"downloads": -1,
"filename": "weedi-1.0.tar.gz",
"has_sig": false,
"md5_digest": "79a4527f1ce1ee9cf4d67b5d1088ff5d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6691,
"upload_time": "2016-09-19T11:10:31",
"url": "https://files.pythonhosted.org/packages/0e/55/8ce9c349a059a623db45495340fafbac823466c8bc2895d10128db3a83c5/weedi-1.0.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "a730c24b389cc35306ae3931b97d8759",
"sha256": "c2e0bb7afd51755b4e426952886e0296f013eb31387e98ecffc1b0cec7bc3ea5"
},
"downloads": -1,
"filename": "weedi-1.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "a730c24b389cc35306ae3931b97d8759",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 10234,
"upload_time": "2016-09-19T11:11:13",
"url": "https://files.pythonhosted.org/packages/22/78/82104779e8b737a8f53fe46481d7f6599d8bb3304d107fc1d3e0cf5804af/weedi-1.0-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "79a4527f1ce1ee9cf4d67b5d1088ff5d",
"sha256": "5b2e7df91a6b46bbba72935572a11469ba53e108b8fb6f2dc64d9424d755b30f"
},
"downloads": -1,
"filename": "weedi-1.0.tar.gz",
"has_sig": false,
"md5_digest": "79a4527f1ce1ee9cf4d67b5d1088ff5d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6691,
"upload_time": "2016-09-19T11:10:31",
"url": "https://files.pythonhosted.org/packages/0e/55/8ce9c349a059a623db45495340fafbac823466c8bc2895d10128db3a83c5/weedi-1.0.tar.gz"
}
]
}